Ignore:
Timestamp:
2021-04-08T22:56:06+02:00 (4 years ago)
Author:
simon04
Message:

see #14176 - Migrate GPX to Instant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java

    r17275 r17715  
    88import java.io.IOException;
    99import java.text.DecimalFormat;
    10 import java.text.ParseException;
    11 import java.text.SimpleDateFormat;
    12 import java.util.Date;
     10import java.time.Instant;
    1311
    1412import org.junit.jupiter.api.BeforeEach;
     
    4846    /**
    4947     * Test time extraction
    50      * @throws ParseException if {@link ExifReader#readTime} fails to parse date/time of sample file
    5148     */
    5249    @Test
    53     void testReadTime() throws ParseException {
    54         Date date = 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);
    5653    }
    5754
    5855    /**
    5956     * Tests reading sub-seconds from the EXIF header
    60      * @throws ParseException if {@link ExifReader#readTime} fails to parse date/time of sample file
    6157     */
    6258    @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);
    7062    }
    7163
    7264    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);
    7467    }
    7568
     
    125118    @Test
    126119    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");
    128121    }
    129122
     
    134127    @Test
    135128    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");
    138131    }
    139132}
Note: See TracChangeset for help on using the changeset viewer.