Changeset 14067 in josm for trunk/test/unit/org
- Timestamp:
- 2018-07-30T21:57:20+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java
r14010 r14067 6 6 import static org.junit.Assert.assertTrue; 7 7 8 import java.io.ByteArrayInputStream; 8 9 import java.io.FileInputStream; 9 10 import java.io.IOException; 11 import java.nio.charset.StandardCharsets; 10 12 import java.text.SimpleDateFormat; 11 13 import java.util.ArrayList; 14 import java.util.Date; 12 15 import java.util.List; 13 16 import java.util.TimeZone; 14 17 18 import org.junit.Before; 15 19 import org.junit.Rule; 16 20 import org.junit.Test; … … 40 44 public JOSMTestRules test = new JOSMTestRules(); 41 45 46 private final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); 47 48 /** 49 * Forces the timezone. 50 */ 51 @Before 52 public void setUp() { 53 iso8601.setTimeZone(TimeZone.getTimeZone("UTC")); 54 } 55 42 56 /** 43 57 * Tests reading a nmea file. … … 58 72 assertEquals(wayPoints.get(0).getTime(), DateUtils.fromString(wayPoints.get(0).get(GpxConstants.PT_TIME).toString())); 59 73 60 final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); 61 assertEquals("2016-01-25T06:05:09.200+01", iso8601.format(wayPoints.get(0).getTime())); 62 assertEquals("2016-01-25T06:05:09.400+01", iso8601.format(wayPoints.get(1).getTime())); 63 assertEquals("2016-01-25T06:05:09.600+01", iso8601.format(wayPoints.get(2).getTime())); 74 assertEquals("2016-01-25T05:05:09.200Z", iso8601.format(wayPoints.get(0).getTime())); 75 assertEquals("2016-01-25T05:05:09.400Z", iso8601.format(wayPoints.get(1).getTime())); 76 assertEquals("2016-01-25T05:05:09.600Z", iso8601.format(wayPoints.get(2).getTime())); 64 77 65 78 assertEquals(new LatLon(46.98807, -1.400525), wayPoints.get(0).getCoor()); … … 146 159 compareWithReference(14924, "input", 0); 147 160 } 161 162 private static Date readDate(String nmeaLine) throws IOException, SAXException { 163 NmeaReader in = new NmeaReader(new ByteArrayInputStream(nmeaLine.getBytes(StandardCharsets.UTF_8))); 164 in.parse(true); 165 return in.data.tracks.iterator().next().getSegments().iterator().next().getWayPoints().iterator().next().getTime(); 166 } 167 168 /** 169 * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/16496">Bug #16496</a>. 170 * @throws Exception if an error occurs 171 */ 172 @Test 173 public void testTicket16496() throws Exception { 174 assertEquals("2018-05-30T16:28:59.400Z", iso8601.format(readDate("$GNRMC,162859.400,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*13"))); 175 assertEquals("2018-05-30T16:28:59.400Z", iso8601.format(readDate("$GNRMC,162859.40,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*23"))); 176 assertEquals("2018-05-30T16:28:59.400Z", iso8601.format(readDate("$GNRMC,162859.4,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*13"))); 177 } 148 178 }
Note:
See TracChangeset
for help on using the changeset viewer.