Changeset 16412 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r15716 r16412 56 56 // CHECKSTYLE.OFF: SingleSpaceSeparator 57 57 // WMS 1.0 - 1.3.0 58 private static final QName CAPABILITI TES_ROOT_130 = new QName("WMS_Capabilities", WMS_NS_URL);58 private static final QName CAPABILITIES_ROOT_130 = new QName(WMS_NS_URL, "WMS_Capabilities"); 59 59 private static final QName QN_ABSTRACT = new QName(WMS_NS_URL, "Abstract"); 60 60 private static final QName QN_CAPABILITY = new QName(WMS_NS_URL, "Capability"); … … 374 374 375 375 private void attemptGetCapabilities(String url) throws IOException, WMSGetCapabilitiesException { 376 Logging.debug("Trying WMS getcapabilities with url {0}", url);376 Logging.debug("Trying WMS GetCapabilities with url {0}", url); 377 377 try (CachedFile cf = new CachedFile(url); InputStream in = cf.setHttpHeaders(headers). 378 378 setMaxAge(7 * CachedFile.DAYS). … … 385 385 if (event == XMLStreamReader.START_ELEMENT) { 386 386 if (tagEquals(CAPABILITIES_ROOT_111, reader.getName())) { 387 // version 1.1.1 388 this.version = reader.getAttributeValue(null, "version"); 389 if (this.version == null) { 390 this.version = "1.1.1"; 391 } 387 this.version = Utils.firstNotEmptyString("1.1.1", 388 reader.getAttributeValue(null, "version")); 392 389 } 393 if (tagEquals(CAPABILITITES_ROOT_130, reader.getName())) { 394 this.version = reader.getAttributeValue(WMS_NS_URL, "version"); 390 if (tagEquals(CAPABILITIES_ROOT_130, reader.getName())) { 391 this.version = Utils.firstNotEmptyString("1.3.0", 392 reader.getAttributeValue(WMS_NS_URL, "version"), 393 reader.getAttributeValue(null, "version")); 395 394 } 396 395 if (tagEquals(QN_SERVICE, reader.getName())) { -
trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java
r14411 r16412 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNull; 5 6 import static org.junit.Assert.assertTrue; 6 7 … … 84 85 @Test 85 86 public void testTicket16248() throws IOException, WMSGetCapabilitiesException { 86 tileServer.stubFor( 87 WireMock.get(WireMock.anyUrl()) 88 .willReturn(WireMock.aResponse().withBody( 89 Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(16248, "capabilities.xml"))) 90 )) 91 ); 87 byte[] capabilities = Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(16248, "capabilities.xml"))); 88 tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(capabilities))); 92 89 WMSImagery wms = new WMSImagery(tileServer.url("any")); 93 90 assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k?", wms.buildRootUrl()); 94 91 assertEquals("wms.hgis.cartomatic.pl", wms.getLayers().get(0).getName()); 95 assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&" 96 + "LAYERS=wms.hgis.cartomatic.pl&STYLES=&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}", 92 assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.3.0&SERVICE=WMS&REQUEST=GetMap&" 93 + "LAYERS=wms.hgis.cartomatic.pl&STYLES=&CRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}", 94 wms.buildGetMapUrl(wms.getLayers(), (List<String>) null, true)); 95 } 96 97 /** 98 * Non-regression test for bug #19193. 99 * @throws IOException if any I/O error occurs 100 * @throws WMSGetCapabilitiesException never 101 */ 102 @Test 103 public void testTicket19193() throws IOException, WMSGetCapabilitiesException { 104 byte[] capabilities = Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(19193, "capabilities.xml"))); 105 tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(capabilities))); 106 WMSImagery wms = new WMSImagery(tileServer.url("any")); 107 assertEquals("https://inspire.brandenburg.de/services/gn_alkis_wms?", wms.buildRootUrl()); 108 assertEquals(1, wms.getLayers().size()); 109 assertNull(wms.getLayers().get(0).getName()); 110 assertEquals("INSPIRE GN ALKIS BB", wms.getLayers().get(0).getTitle()); 111 assertEquals("https://inspire.brandenburg.de/services/gn_alkis_wms?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.3.0&" 112 + "SERVICE=WMS&REQUEST=GetMap&LAYERS=null&STYLES=&CRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}", 97 113 wms.buildGetMapUrl(wms.getLayers(), (List<String>) null, true)); 98 114 }
Note:
See TracChangeset
for help on using the changeset viewer.