Changeset 17715 in josm for trunk/test/unit/org/openstreetmap/josm/tools
- Timestamp:
- 2021-04-08T22:56:06+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.