Ignore:
Timestamp:
2018-09-02T21:53:46+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #16695 - display remark from Overpass API when a download returns no data

Location:
trunk/test/unit/org/openstreetmap/josm/io
Files:
2 edited

Legend:

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

    r14201 r14219  
    5353     */
    5454    private static DataSet parse(String osm) throws Exception {
     55        return parse(osm, "");
     56    }
     57
     58    /**
     59     * Parse JSON.
     60     * @param osm OSM data in JSON format, without header/footer
     61     * @param extraContent extra content added after OSM elements
     62     * @return data set
     63     * @throws Exception if any error occurs
     64     */
     65    private static DataSet parse(String osm, String extraContent) throws Exception {
    5566        try (InputStream in = new ByteArrayInputStream((
    5667                "{\n" +
     
    6576                "  },\n" +
    6677                "  \"elements\": [" + osm + "]\n" +
     78                extraContent +
    6779                "}")
    6880                .getBytes(StandardCharsets.UTF_8))) {
     
    225237        assertEquals("route", r.get("type"));
    226238    }
     239
     240    /**
     241     * Test reading remark from Overpass API.
     242     * @throws Exception if any error occurs
     243     */
     244    @Test
     245    public void testRemark() throws Exception {
     246        DataSet ds = parse("", "," +
     247                "  \"remark\": \"runtime error: Query ran out of memory in \\\"query\\\" at line 5.\"\n");
     248        assertEquals("runtime error: Query ran out of memory in \"query\" at line 5.", ds.getRemark());
     249    }
    227250}
  • trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java

    r14078 r14219  
    115115     * Test valid data.
    116116     * @param osm OSM data without XML prefix
    117      * @throws Exception if any error occurs
    118      */
    119     private static void testValidData(String osm) throws Exception {
     117     * @return parsed data set
     118     * @throws Exception if any error occurs
     119     */
     120    private static DataSet testValidData(String osm) throws Exception {
    120121        try (InputStream in = new ByteArrayInputStream(
    121122                ("<?xml version='1.0' encoding='UTF-8'?>" + osm).getBytes(StandardCharsets.UTF_8))) {
    122             OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
     123            return OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
    123124        }
    124125    }
     
    341342        }
    342343    }
     344
     345    /**
     346     * Test reading remark from Overpass API.
     347     * @throws Exception if any error occurs
     348     */
     349    @Test
     350    public void testRemark() throws Exception {
     351        DataSet ds = testValidData(
     352                "<osm version=\"0.6\" generator=\"Overpass API 0.7.55.4 3079d8ea\">\r\n" +
     353                "<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>\r\n" +
     354                "<meta osm_base=\"2018-08-30T12:46:02Z\" areas=\"2018-08-30T12:40:02Z\"/>\r\n" +
     355                "<remark>runtime error: Query ran out of memory in \"query\" at line 5.</remark>\r\n" +
     356                "</osm>");
     357        assertEquals("runtime error: Query ran out of memory in \"query\" at line 5.", ds.getRemark());
     358    }
    343359}
Note: See TracChangeset for help on using the changeset viewer.