Changeset 17715 in josm for trunk/test
- Timestamp:
- 2021-04-08T22:56:06+02:00 (4 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/ImageDataTest.java
r17310 r17715 8 8 9 9 import java.io.File; 10 import java.time.Instant; 10 11 import java.util.ArrayList; 11 12 import java.util.Arrays; 12 13 import java.util.Collections; 13 import java.util.Date;14 14 import java.util.List; 15 15 … … 28 28 class ImageDataTest { 29 29 30 private static ImageEntry newImageEntry(String file, DateexifTime) {30 private static ImageEntry newImageEntry(String file, Instant exifTime) { 31 31 ImageEntry entry = new ImageEntry(new File(file)); 32 32 entry.setExifTime(exifTime); … … 65 65 @Test 66 66 void testSortData() { 67 ImageEntry entry1 = newImageEntry("test1", new Date(1_000_000));68 ImageEntry entry2 = newImageEntry("test2", new Date(2_000_000));67 ImageEntry entry1 = newImageEntry("test1", Instant.ofEpochMilli(1_000_000)); 68 ImageEntry entry2 = newImageEntry("test2", Instant.ofEpochMilli(2_000_000)); 69 69 70 70 ArrayList<ImageEntry> list = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
r17275 r17715 10 10 11 11 import java.io.IOException; 12 import java.time.Instant; 12 13 import java.util.ArrayList; 13 14 import java.util.Arrays; … … 337 338 WayPoint p4 = new WayPoint(LatLon.NORTH_POLE); 338 339 WayPoint p5 = new WayPoint(LatLon.NORTH_POLE); 339 p1.set Time(new Date(200020));340 p2.set Time(new Date(100020));341 p4.set Time(new Date(500020));340 p1.setInstant(new Date(200020).toInstant()); 341 p2.setInstant(new Date(100020).toInstant()); 342 p4.setInstant(new Date(500020).toInstant()); 342 343 data.addTrack(new GpxTrack(Arrays.asList(Arrays.asList(p1, p2)), Collections.emptyMap())); 343 344 data.addTrack(new GpxTrack(Arrays.asList(Arrays.asList(p3, p4, p5)), Collections.emptyMap())); 344 345 345 Date[] times = data.getMinMaxTimeForAllTracks();346 Instant[] times = data.getMinMaxTimeForAllTracks(); 346 347 assertEquals(times.length, 2); 347 assertEquals( new Date(100020), times[0]);348 assertEquals( new Date(500020), times[1]);348 assertEquals(Instant.ofEpochMilli(100020), times[0]); 349 assertEquals(Instant.ofEpochMilli(500020), times[1]); 349 350 } 350 351 -
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxImageCorrelationTest.java
r17275 r17715 58 58 59 59 final GpxImageEntry ib = new GpxImageEntry(); 60 ib.setExifTime(DateUtils. fromString("2016:01:03 11:54:58")); // 5 minutes before start of GPX60 ib.setExifTime(DateUtils.parseInstant("2016:01:03 11:54:58")); // 5 minutes before start of GPX 61 61 ib.createTmp(); 62 62 final GpxImageEntry i0 = new GpxImageEntry(); 63 i0.setExifTime(DateUtils. fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX63 i0.setExifTime(DateUtils.parseInstant("2016:01:03 11:59:54")); // 4 sec before start of GPX 64 64 i0.createTmp(); 65 65 final GpxImageEntry i1 = new GpxImageEntry(); 66 i1.setExifTime(DateUtils. fromString("2016:01:03 12:04:01"));66 i1.setExifTime(DateUtils.parseInstant("2016:01:03 12:04:01")); 67 67 i1.createTmp(); 68 68 final GpxImageEntry i2 = new GpxImageEntry(); 69 i2.setExifTime(DateUtils. fromString("2016:01:03 12:04:57"));69 i2.setExifTime(DateUtils.parseInstant("2016:01:03 12:04:57")); 70 70 i2.createTmp(); 71 71 final GpxImageEntry i3 = new GpxImageEntry(); 72 i3.setExifTime(DateUtils. fromString("2016:01:03 12:05:05"));72 i3.setExifTime(DateUtils.parseInstant("2016:01:03 12:05:05")); 73 73 i3.createTmp(); 74 74 final GpxImageEntry i4 = new GpxImageEntry(); //Image close to two points with elevation, but without time 75 i4.setExifTime(DateUtils. fromString("2016:01:03 12:05:20"));75 i4.setExifTime(DateUtils.parseInstant("2016:01:03 12:05:20")); 76 76 i4.createTmp(); 77 77 final GpxImageEntry i5 = new GpxImageEntry(); //between two tracks, closer to first 78 i5.setExifTime(DateUtils. fromString("2016:01:03 12:07:00"));78 i5.setExifTime(DateUtils.parseInstant("2016:01:03 12:07:00")); 79 79 i5.createTmp(); 80 80 final GpxImageEntry i6 = new GpxImageEntry(); //between two tracks, closer to second (more than 1 minute from any track) 81 i6.setExifTime(DateUtils. fromString("2016:01:03 12:07:45"));81 i6.setExifTime(DateUtils.parseInstant("2016:01:03 12:07:45")); 82 82 i6.createTmp(); 83 83 … … 119 119 assertEquals(null, i6.getElevation()); 120 120 121 assertEquals(null, ib.getGps Time());122 assertEquals(DateUtils. fromString("2016:01:03 11:59:54"), i0.getGpsTime()); // original time is kept123 assertEquals(DateUtils. fromString("2016:01:03 12:04:01"), i1.getGpsTime());124 assertEquals(DateUtils. fromString("2016:01:03 12:04:57"), i2.getGpsTime());125 assertEquals(DateUtils. fromString("2016:01:03 12:05:05"), i3.getGpsTime());121 assertEquals(null, ib.getGpsInstant()); 122 assertEquals(DateUtils.parseInstant("2016:01:03 11:59:54"), i0.getGpsInstant()); // original time is kept 123 assertEquals(DateUtils.parseInstant("2016:01:03 12:04:01"), i1.getGpsInstant()); 124 assertEquals(DateUtils.parseInstant("2016:01:03 12:04:57"), i2.getGpsInstant()); 125 assertEquals(DateUtils.parseInstant("2016:01:03 12:05:05"), i3.getGpsInstant()); 126 126 127 127 clearTmp(images); -
trunk/test/unit/org/openstreetmap/josm/data/gpx/WayPointTest.java
r17275 r17715 5 5 import org.junit.jupiter.api.Test; 6 6 import org.openstreetmap.josm.TestUtils; 7 import org.openstreetmap.josm.data.coor.LatLon; 7 8 import org.openstreetmap.josm.testutils.JOSMTestRules; 8 9 … … 10 11 import nl.jqno.equalsverifier.EqualsVerifier; 11 12 import nl.jqno.equalsverifier.Warning; 13 14 import java.time.Instant; 15 16 import static org.junit.jupiter.api.Assertions.assertEquals; 17 import static org.junit.jupiter.api.Assertions.assertNotEquals; 12 18 13 19 /** … … 37 43 .verify(); 38 44 } 45 46 /** 47 * Unit test of copy constructor {@link WayPoint#WayPoint(WayPoint)} 48 */ 49 @Test 50 void testConstructor() { 51 WayPoint wp1 = new WayPoint(new LatLon(12., 34.)); 52 wp1.setInstant(Instant.ofEpochMilli(123_456_789)); 53 WayPoint wp2 = new WayPoint(wp1); 54 assertEquals(wp1, wp2); 55 assertEquals(wp1.getInstant(), wp2.getInstant()); 56 wp2.setInstant(Instant.ofEpochMilli(234_456_789)); 57 assertNotEquals(wp1, wp2); 58 assertNotEquals(wp1.getInstant(), wp2.getInstant()); 59 } 39 60 } -
trunk/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
r17275 r17715 10 10 import java.io.File; 11 11 import java.nio.charset.StandardCharsets; 12 import java.text.DateFormat;13 12 import java.util.Collection; 14 13 import java.util.Collections; … … 39 38 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 40 39 import org.openstreetmap.josm.tools.Logging; 41 import org.openstreetmap.josm.tools.date.DateUtils;42 40 43 41 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 245 243 assertEquals(3, trackpoints.size()); 246 244 Iterator<WayPoint> it = trackpoints.iterator(); 247 DateFormat gpxFormat = DateUtils.getGpxFormat();248 245 WayPoint p1 = it.next(); 249 246 assertEquals(new LatLon(47.0, 9.0), p1.getCoor()); 250 247 assertEquals("123", p1.get(GpxConstants.PT_ELE)); 251 assertEquals("2018-08-01T10:00:00 .000Z", gpxFormat.format(p1.get(GpxConstants.PT_TIME)));248 assertEquals("2018-08-01T10:00:00Z", String.valueOf(p1.get(GpxConstants.PT_TIME))); 252 249 WayPoint p2 = it.next(); 253 250 assertEquals(new LatLon(47.1, 9.1), p2.getCoor()); 254 251 assertEquals("456", p2.get(GpxConstants.PT_ELE)); 255 assertEquals("2018-08-01T10:01:00 .000Z", gpxFormat.format(p2.get(GpxConstants.PT_TIME)));252 assertEquals("2018-08-01T10:01:00Z", String.valueOf(p2.get(GpxConstants.PT_TIME))); 256 253 WayPoint p3 = it.next(); 257 254 assertEquals(new LatLon(47.05, 9.05), p3.getCoor()); 258 255 assertEquals("789", p3.get(GpxConstants.PT_ELE)); 259 assertEquals("2018-08-01T10:02:00 .000Z", gpxFormat.format(p3.get(GpxConstants.PT_TIME)));256 assertEquals("2018-08-01T10:02:00Z", String.valueOf(p3.get(GpxConstants.PT_TIME))); 260 257 } 261 258 -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImagesTest.java
r17275 r17715 48 48 final GpxData gpx = GpxReaderTest.parseGpxData("nodist/data/2094047.gpx"); 49 49 final ImageEntry i0 = new ImageEntry(); 50 i0.setExifTime(DateUtils. fromString("2016:01:03 11:59:54")); // 4 sec before start of GPX50 i0.setExifTime(DateUtils.parseInstant("2016:01:03 11:59:54")); // 4 sec before start of GPX 51 51 i0.createTmp(); 52 52 assertEquals(Pair.create(GpxTimezone.ZERO, GpxTimeOffset.seconds(-4)), -
trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImageEntryTest.java
r17580 r17715 27 27 ImageEntry e = new ImageEntry(new File(TestUtils.getRegressionDataFile(12255, "G0016941.JPG"))); 28 28 e.extractExif(); 29 assertNotNull(e.getExif Time());29 assertNotNull(e.getExifInstant()); 30 30 } 31 31 -
trunk/test/unit/org/openstreetmap/josm/io/nmea/NmeaReaderTest.java
r17275 r17715 11 11 import java.nio.file.Files; 12 12 import java.nio.file.Paths; 13 import java.t ext.SimpleDateFormat;13 import java.time.Instant; 14 14 import java.util.ArrayList; 15 import java.util.Date;16 15 import java.util.List; 17 16 import java.util.TimeZone; 18 17 19 import org.junit.jupiter.api.BeforeEach;20 18 import org.junit.jupiter.api.Test; 21 19 import org.junit.jupiter.api.extension.RegisterExtension; … … 45 43 public JOSMTestRules test = new JOSMTestRules(); 46 44 47 private final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");48 49 /**50 * Forces the timezone.51 */52 @BeforeEach53 public void setUp() {54 iso8601.setTimeZone(DateUtils.UTC);55 }56 57 45 /** 58 46 * Tests reading a nmea file. … … 68 56 69 57 final List<WayPoint> wayPoints = new ArrayList<>(in.data.tracks.iterator().next().getSegments().iterator().next().getWayPoints()); 70 assertEquals(DateUtils. fromString("2016-01-25T05:05:09.200Z"), wayPoints.get(0).get(GpxConstants.PT_TIME));71 assertEquals(DateUtils. fromString("2016-01-25T05:05:09.400Z"), wayPoints.get(1).get(GpxConstants.PT_TIME));72 assertEquals(DateUtils. fromString("2016-01-25T05:05:09.600Z"), wayPoints.get(2).get(GpxConstants.PT_TIME));73 assertEquals(wayPoints.get(0).get Date(), wayPoints.get(0).get(GpxConstants.PT_TIME));58 assertEquals(DateUtils.parseInstant("2016-01-25T05:05:09.200Z"), wayPoints.get(0).get(GpxConstants.PT_TIME)); 59 assertEquals(DateUtils.parseInstant("2016-01-25T05:05:09.400Z"), wayPoints.get(1).get(GpxConstants.PT_TIME)); 60 assertEquals(DateUtils.parseInstant("2016-01-25T05:05:09.600Z"), wayPoints.get(2).get(GpxConstants.PT_TIME)); 61 assertEquals(wayPoints.get(0).getInstant(), wayPoints.get(0).get(GpxConstants.PT_TIME)); 74 62 75 assertEquals("2016-01-25T05:05:09.200Z" , iso8601.format(wayPoints.get(0).getDate()));76 assertEquals("2016-01-25T05:05:09.400Z" , iso8601.format(wayPoints.get(1).getDate()));77 assertEquals("2016-01-25T05:05:09.600Z" , iso8601.format(wayPoints.get(2).getDate()));63 assertEquals(DateUtils.parseInstant("2016-01-25T05:05:09.200Z"), wayPoints.get(0).getInstant()); 64 assertEquals(DateUtils.parseInstant("2016-01-25T05:05:09.400Z"), wayPoints.get(1).getInstant()); 65 assertEquals(DateUtils.parseInstant("2016-01-25T05:05:09.600Z"), wayPoints.get(2).getInstant()); 78 66 79 67 assertEquals(new LatLon(46.98807, -1.400525), wayPoints.get(0).getCoor()); … … 171 159 } 172 160 173 private static DatereadDate(String nmeaLine) throws IOException, SAXException {174 return readWayPoint(nmeaLine).get Date();161 private static Instant readDate(String nmeaLine) throws IOException, SAXException { 162 return readWayPoint(nmeaLine).getInstant(); 175 163 } 176 164 … … 185 173 @Test 186 174 void testTicket16496() throws Exception { 187 assertEquals("2018-05-30T16:28:59.400Z" , iso8601.format(188 readDate("$GNRMC,162859.400,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*13")) );189 assertEquals("2018-05-30T16:28:59.400Z" , iso8601.format(190 readDate("$GNRMC,162859.40,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*23")) );191 assertEquals("2018-05-30T16:28:59.400Z" , iso8601.format(192 readDate("$GNRMC,162859.4,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*13")) );175 assertEquals(DateUtils.parseInstant("2018-05-30T16:28:59.400Z"), 176 readDate("$GNRMC,162859.400,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*13")); 177 assertEquals(DateUtils.parseInstant("2018-05-30T16:28:59.400Z"), 178 readDate("$GNRMC,162859.40,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*23")); 179 assertEquals(DateUtils.parseInstant("2018-05-30T16:28:59.400Z"), 180 readDate("$GNRMC,162859.4,A,4543.03388,N,00058.19870,W,45.252,209.07,300518,,,D,V*13")); 193 181 } 194 182 -
trunk/test/unit/org/openstreetmap/josm/io/rtklib/RtkLibPosReaderTest.java
r17275 r17715 7 7 import java.nio.file.Files; 8 8 import java.nio.file.Paths; 9 import java.t ext.SimpleDateFormat;9 import java.time.Instant; 10 10 import java.util.ArrayList; 11 11 import java.util.List; 12 12 import java.util.TimeZone; 13 13 14 import org.junit.jupiter.api.BeforeEach;15 14 import org.junit.jupiter.api.Test; 16 15 import org.junit.jupiter.api.extension.RegisterExtension; … … 35 34 public JOSMTestRules test = new JOSMTestRules(); 36 35 37 private final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX");38 39 /**40 * Forces the timezone.41 */42 @BeforeEach43 public void setUp() {44 iso8601.setTimeZone(DateUtils.UTC);45 }46 47 36 private static RtkLibPosReader read(String path) throws IOException, SAXException { 48 37 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); … … 62 51 63 52 List<WayPoint> wayPoints = new ArrayList<>(in.getGpxData().tracks.iterator().next().getSegments().iterator().next().getWayPoints()); 64 assertEquals(DateUtils. fromString("2019-06-08T08:23:12.000Z"), wayPoints.get(0).get(GpxConstants.PT_TIME));65 assertEquals(DateUtils. fromString("2019-06-08T08:23:12.300Z"), wayPoints.get(1).get(GpxConstants.PT_TIME));66 assertEquals(DateUtils. fromString("2019-06-08T08:23:12.600Z"), wayPoints.get(2).get(GpxConstants.PT_TIME));67 assertEquals(wayPoints.get(0).get Date(), wayPoints.get(0).get(GpxConstants.PT_TIME));53 assertEquals(DateUtils.parseInstant("2019-06-08T08:23:12.000Z"), wayPoints.get(0).get(GpxConstants.PT_TIME)); 54 assertEquals(DateUtils.parseInstant("2019-06-08T08:23:12.300Z"), wayPoints.get(1).get(GpxConstants.PT_TIME)); 55 assertEquals(DateUtils.parseInstant("2019-06-08T08:23:12.600Z"), wayPoints.get(2).get(GpxConstants.PT_TIME)); 56 assertEquals(wayPoints.get(0).getInstant(), wayPoints.get(0).get(GpxConstants.PT_TIME)); 68 57 69 assertEquals("2019-06-08T08:23:12.000Z" , iso8601.format(wayPoints.get(0).getDate()));70 assertEquals("2019-06-08T08:23:12.300Z" , iso8601.format(wayPoints.get(1).getDate()));71 assertEquals("2019-06-08T08:23:12.600Z" , iso8601.format(wayPoints.get(2).getDate()));58 assertEquals(Instant.parse("2019-06-08T08:23:12.000Z"), wayPoints.get(0).getInstant()); 59 assertEquals(Instant.parse("2019-06-08T08:23:12.300Z"), wayPoints.get(1).getInstant()); 60 assertEquals(Instant.parse("2019-06-08T08:23:12.600Z"), wayPoints.get(2).getInstant()); 72 61 73 62 assertEquals(new LatLon(46.948881673, -1.484757046), wayPoints.get(0).getCoor()); -
trunk/test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java
r17275 r17715 8 8 import java.io.IOException; 9 9 import java.text.DecimalFormat; 10 import java.text.ParseException; 11 import java.text.SimpleDateFormat; 12 import java.util.Date; 10 import java.time.Instant; 13 11 14 12 import org.junit.jupiter.api.BeforeEach; … … 48 46 /** 49 47 * Test time extraction 50 * @throws ParseException if {@link ExifReader#readTime} fails to parse date/time of sample file51 48 */ 52 49 @Test 53 void testReadTime() throws ParseException{54 Datedate = ExifReader.readTime(directionSampleFile);55 doTest("2010-05-15T17:12:05.000", date);50 void testReadTime() { 51 Instant date = ExifReader.readInstant(directionSampleFile); 52 assertEquals(Instant.parse("2010-05-15T17:12:05.000Z"), date); 56 53 } 57 54 58 55 /** 59 56 * Tests reading sub-seconds from the EXIF header 60 * @throws ParseException if {@link ExifReader#readTime} fails to parse date/time of sample file61 57 */ 62 58 @Test 63 void testReadTimeSubSecond1() throws ParseException { 64 Date date = ExifReader.readTime(new File("nodist/data/IMG_20150711_193419.jpg")); 65 doTest("2015-07-11T19:34:19.100", date); 66 } 67 68 private static void doTest(String expectedDate, Date parsedDate) { 69 assertEquals(expectedDate, new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").format(parsedDate)); 59 void testReadTimeSubSecond1() { 60 Instant date = ExifReader.readInstant(new File("nodist/data/IMG_20150711_193419.jpg")); 61 assertEquals(Instant.parse("2015-07-11T19:34:19.100Z"), date); 70 62 } 71 63 72 64 private static void doTestFile(String expectedDate, int ticket, String filename) { 73 doTest(expectedDate, ExifReader.readTime(new File(TestUtils.getRegressionDataFile(ticket, filename)))); 65 Instant date = ExifReader.readInstant(new File(TestUtils.getRegressionDataFile(ticket, filename))); 66 assertEquals(Instant.parse(expectedDate), date); 74 67 } 75 68 … … 125 118 @Test 126 119 void testTicket11685() throws IOException { 127 doTestFile("2015-11-08T15:33:27.500", 11685, "2015-11-08_15-33-27-Xiaomi_YI-Y0030832.jpg"); 120 doTestFile("2015-11-08T15:33:27.500Z", 11685, "2015-11-08_15-33-27-Xiaomi_YI-Y0030832.jpg"); 128 121 } 129 122 … … 134 127 @Test 135 128 void testTicket14209() throws IOException { 136 doTestFile("2017-01-16T18:27:00.000", 14209, "0MbEfj1S--.1.jpg"); 137 doTestFile("2016-08-13T19:51:13.000", 14209, "7VWFOryj--.1.jpg"); 129 doTestFile("2017-01-16T18:27:00.000Z", 14209, "0MbEfj1S--.1.jpg"); 130 doTestFile("2016-08-13T19:51:13.000Z", 14209, "7VWFOryj--.1.jpg"); 138 131 } 139 132 }
Note:
See TracChangeset
for help on using the changeset viewer.