Changeset 14243 in josm for trunk/test


Ignore:
Timestamp:
2018-09-10T20:31:22+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16725 - numeric attributes of GPX waypoints were no longer exported (regression from #14103)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/GpxWriterTest.java

    r14080 r14243  
    1111import java.time.ZoneOffset;
    1212import java.util.Date;
     13import java.util.function.Consumer;
    1314
    1415import org.junit.Rule;
     
    3435    public JOSMTestRules test = new JOSMTestRules();
    3536
    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 {
    4238        GpxData gpx = new GpxData();
    4339        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);
    4541        gpx.addWaypoint(waypoint);
    4642        ByteArrayOutputStream baos = new ByteArrayOutputStream();
     
    4844            writer.write(gpx);
    4945        }
    50         // Checks that time stored as date is correctly written into XML timestamp
    5146        assertEquals(String.format("<?xml version='1.0' encoding='UTF-8'?>%n" +
    5247                "<gpx version=\"1.1\" creator=\"JOSM GPX export\" xmlns=\"http://www.topografix.com/GPX/1/1\"%n" +
     
    5752                "  </metadata>%n" +
    5853                "  <wpt lat=\"0.0\" lon=\"0.0\">%n" +
    59                 "    <time>2018-08-02T00:00:00.000Z</time>%n" +
     54                atts +
    6055                "  </wpt>%n" +
    6156                "</gpx>"), baos.toString(StandardCharsets.UTF_8.name()));
    6257    }
     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    }
    6390}
Note: See TracChangeset for help on using the changeset viewer.