Changeset 19646 in josm for trunk/test/unit


Ignore:
Timestamp:
2026-10-09T18:21:45+02:00 (5 days ago)
Author:
gaben
Message:

see #24927 - report non-OSM JSON (e.g. GeoJSON from Postpass) as illegal data instead of crashing

File:
1 edited

Legend:

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

    r18816 r19646  
    260260    }
    261261
     262    /**
     263     * Non-regression test for ticket #24927. GeoJSON served as {@code application/json} (e.g. by Postpass)
     264     * must be reported as illegal data, not crash the reader.
     265     */
     266    @Test
     267    void testTicket24927() {
     268        byte[] geoJson = ("{\"type\": \"FeatureCollection\", \"features\": [{\"type\": \"Feature\", " +
     269                "\"geometry\": {\"type\": \"Point\", \"coordinates\": [10.1, 20.2]}, " +
     270                "\"properties\": {\"tags\": {\"fixme\": \"yes\"}}}]}").getBytes(StandardCharsets.UTF_8);
     271        IllegalDataException exception = assertThrows(IllegalDataException.class,
     272                () -> OsmJsonReader.parseDataSet(new ByteArrayInputStream(geoJson), NullProgressMonitor.INSTANCE));
     273        assertEquals("Missing mandatory attribute 'version'.", exception.getMessage());
     274    }
     275
    262276    static Stream<Arguments> testException() {
    263277        final byte[] smallJson = "{\"type\", \"node\", \"id\": 1, \"lat\": 1.0, \"lon\": 2.0}".getBytes(StandardCharsets.UTF_8);
Note: See TracChangeset for help on using the changeset viewer.