Ignore:
Timestamp:
2018-12-15T21:00:08+01:00 (5 years ago)
Author:
Don-vip
Message:

see #16073 - detection of json errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java

    r14311 r14565  
    174174    }
    175175
     176    /**
     177     * Tests that {@code TMSCachedTileLoaderJob#JSON_PATTERN} is correct.
     178     */
     179    @Test
     180    public void testJsonPattern() {
     181        testJson("Tile does not exist",
     182                "{\"message\":\"Tile does not exist\"}");
     183    }
     184
    176185    private static void testServiceException(String expected, String xml) {
    177186        test(TMSCachedTileLoaderJob.SERVICE_EXCEPTION_PATTERN, expected, xml);
     
    182191    }
    183192
    184     private static void test(Pattern pattern, String expected, String xml) {
    185         Matcher m = pattern.matcher(xml);
    186         assertTrue(xml, m.matches());
     193    private static void testJson(String expected, String json) {
     194        test(TMSCachedTileLoaderJob.JSON_PATTERN, expected, json);
     195    }
     196
     197    private static void test(Pattern pattern, String expected, String text) {
     198        Matcher m = pattern.matcher(text);
     199        assertTrue(text, m.matches());
    187200        assertEquals(expected, Utils.strip(m.group(1)));
    188201    }
Note: See TracChangeset for help on using the changeset viewer.