Changeset 14219 in josm for trunk/test/unit/org/openstreetmap/josm
- Timestamp:
- 2018-09-02T21:53:46+02:00 (6 years ago)
- 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 53 53 */ 54 54 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 { 55 66 try (InputStream in = new ByteArrayInputStream(( 56 67 "{\n" + … … 65 76 " },\n" + 66 77 " \"elements\": [" + osm + "]\n" + 78 extraContent + 67 79 "}") 68 80 .getBytes(StandardCharsets.UTF_8))) { … … 225 237 assertEquals("route", r.get("type")); 226 238 } 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 } 227 250 } -
trunk/test/unit/org/openstreetmap/josm/io/OsmReaderTest.java
r14078 r14219 115 115 * Test valid data. 116 116 * @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 { 120 121 try (InputStream in = new ByteArrayInputStream( 121 122 ("<?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); 123 124 } 124 125 } … … 341 342 } 342 343 } 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 } 343 359 }
Note:
See TracChangeset
for help on using the changeset viewer.