Changeset 14311 in josm for trunk/test/unit/org
- Timestamp:
- 2018-10-09T20:04:07+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java
r13742 r14311 14 14 import java.util.concurrent.TimeUnit; 15 15 import java.util.regex.Matcher; 16 import java.util.regex.Pattern; 16 17 17 18 import org.apache.commons.jcs.access.behavior.ICacheAccess; … … 145 146 @Test 146 147 public void testServiceExceptionPattern() { 147 test ("missing parameters ['version', 'format']",148 testServiceException("missing parameters ['version', 'format']", 148 149 "<?xml version=\"1.0\"?>\n" + 149 150 "<!DOCTYPE ServiceExceptionReport SYSTEM \"http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd\">\n" + … … 151 152 " <ServiceException>missing parameters ['version', 'format']</ServiceException>\n" + 152 153 "</ServiceExceptionReport>"); 153 test ("Parameter 'layers' contains unacceptable layer names.",154 testServiceException("Parameter 'layers' contains unacceptable layer names.", 154 155 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\r\n" + 155 156 "<!DOCTYPE ServiceExceptionReport SYSTEM \"http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd\">\r\n" + … … 162 163 } 163 164 164 private static void test(String expected, String xml) { 165 Matcher m = TMSCachedTileLoaderJob.SERVICE_EXCEPTION_PATTERN.matcher(xml); 165 /** 166 * Tests that {@code TMSCachedTileLoaderJob#CDATA_PATTERN} is correct. 167 */ 168 @Test 169 public void testCdataPattern() { 170 testCdata("received unsuitable wms request: no <grid> with suitable srs found for layer capitais", 171 "<![CDATA[\r\n" + 172 "received unsuitable wms request: no <grid> with suitable srs found for layer capitais\r\n" + 173 "]]>"); 174 } 175 176 private static void testServiceException(String expected, String xml) { 177 test(TMSCachedTileLoaderJob.SERVICE_EXCEPTION_PATTERN, expected, xml); 178 } 179 180 private static void testCdata(String expected, String xml) { 181 test(TMSCachedTileLoaderJob.CDATA_PATTERN, expected, xml); 182 } 183 184 private static void test(Pattern pattern, String expected, String xml) { 185 Matcher m = pattern.matcher(xml); 166 186 assertTrue(xml, m.matches()); 167 187 assertEquals(expected, Utils.strip(m.group(1)));
Note:
See TracChangeset
for help on using the changeset viewer.