Changeset 14243 in josm for trunk/test
- Timestamp:
- 2018-09-10T20:31:22+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/GpxWriterTest.java
r14080 r14243 11 11 import java.time.ZoneOffset; 12 12 import java.util.Date; 13 import java.util.function.Consumer; 13 14 14 15 import org.junit.Rule; … … 34 35 public JOSMTestRules test = new JOSMTestRules(); 35 36 36 /** 37 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/16550">#16550</a> 38 * @throws IOException never 39 */ 40 @Test 41 public void testTicket16550() throws IOException { 37 private static void testSingleWaypoint(Consumer<WayPoint> consumer, String atts) throws IOException { 42 38 GpxData gpx = new GpxData(); 43 39 WayPoint waypoint = new WayPoint(LatLon.ZERO); 44 waypoint.put(GpxConstants.PT_TIME, Date.from(LocalDate.of(2018, Month.AUGUST, 2).atStartOfDay(ZoneOffset.UTC).toInstant()));40 consumer.accept(waypoint); 45 41 gpx.addWaypoint(waypoint); 46 42 ByteArrayOutputStream baos = new ByteArrayOutputStream(); … … 48 44 writer.write(gpx); 49 45 } 50 // Checks that time stored as date is correctly written into XML timestamp51 46 assertEquals(String.format("<?xml version='1.0' encoding='UTF-8'?>%n" + 52 47 "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"%n" + … … 57 52 " </metadata>%n" + 58 53 " <wpt lat=\"0.0\" lon=\"0.0\">%n" + 59 " <time>2018-08-02T00:00:00.000Z</time>%n"+54 atts + 60 55 " </wpt>%n" + 61 56 "</gpx>"), baos.toString(StandardCharsets.UTF_8.name())); 62 57 } 58 59 /** 60 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/16550">#16550</a> 61 * @throws IOException never 62 */ 63 @Test 64 public void testTicket16550() throws IOException { 65 // Checks that time stored as date is correctly written into XML timestamp 66 testSingleWaypoint( 67 w -> w.put(GpxConstants.PT_TIME, Date.from(LocalDate.of(2018, Month.AUGUST, 2).atStartOfDay(ZoneOffset.UTC).toInstant())), 68 " <time>2018-08-02T00:00:00.000Z</time>%n"); 69 } 70 71 /** 72 * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/16725">#16725</a> 73 * @throws IOException never 74 */ 75 @Test 76 public void testTicket16725() throws IOException { 77 // Checks that sat, hdop, pdop, vdop are correctly exported 78 testSingleWaypoint( 79 w -> { 80 w.put(GpxConstants.PT_SAT, 16); 81 w.put(GpxConstants.PT_HDOP, 0.7); 82 w.put(GpxConstants.PT_VDOP, 0.9); 83 w.put(GpxConstants.PT_PDOP, 1.2); 84 }, 85 " <sat>16</sat>%n" + 86 " <hdop>0.7</hdop>%n" + 87 " <vdop>0.9</vdop>%n" + 88 " <pdop>1.2</pdop>%n"); 89 } 63 90 }
Note:
See TracChangeset
for help on using the changeset viewer.