Changeset 13870 in josm


Ignore:
Timestamp:
2018-05-29T22:36:33+02:00 (6 months ago)
Author:
wiktorn
Message:

Fix NPE when style title is null

Closes: #16333

Location:
trunk
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/LayerDetails.java

    r13824 r13870  
    117117     */
    118118    public void addStyle(String name, String title) {
    119         this.styles.put(name, title);
     119        this.styles.put(name, title == null ? "" : title);
    120120    }
    121121
  • trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java

    r13742 r13870  
    9797                wms.buildGetMapUrl(wms.getLayers(), (List<String>) null, true));
    9898    }
     99
     100    /**
     101     * Regression test for bug #16333 (null style name)
     102     * @throws IOException if any I/O error occurs
     103     * @throws WMSGetCapabilitiesException  never
     104     */
     105    @Test
     106    public void testTicket16333() throws IOException, WMSGetCapabilitiesException {
     107        tileServer.stubFor(
     108                WireMock.get(WireMock.anyUrl())
     109                .willReturn(WireMock.aResponse().withBody(
     110                        Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(16333, "capabilities.xml")))
     111                ))
     112        );
     113        WMSImagery wms = new WMSImagery(tileServer.url("any"));
     114        assertEquals("https://duinoord.xs4all.nl/geoserver/ows?SERVICE=WMS&", wms.buildRootUrl());
     115        assertEquals(null, wms.getLayers().get(0).getName());
     116        assertEquals("", wms.getLayers().get(0).getTitle());
     117
     118        assertEquals("bag:Matching Street", wms.getLayers().get(0).getChildren().get(0).getName());
     119        assertEquals("Dichtstbijzijnde straat", wms.getLayers().get(0).getChildren().get(0).getTitle());
     120
     121    }
    99122}
    100123
Note: See TracChangeset for help on using the changeset viewer.