source: josm/trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java@ 13699

Last change on this file since 13699 was 13699, checked in by Don-vip, 7 years ago

fix #16248 - fix parsing of XML namespace in WMS capabilities (patch by Bartosz Firyn, modified)

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io.imagery;
3
4import static org.junit.Assert.assertEquals;
5import static org.junit.Assert.assertTrue;
6
7import java.io.IOException;
8import java.io.InputStream;
9
10import org.junit.Rule;
11import org.junit.Test;
12import org.openstreetmap.josm.TestUtils;
13import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException;
14import org.openstreetmap.josm.testutils.JOSMTestRules;
15
16import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
17
18/**
19 * Unit tests of {@link WMSImagery} class.
20 */
21public class WMSImageryTest {
22
23 /**
24 * Setup test
25 */
26 @Rule
27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
28 public JOSMTestRules test = new JOSMTestRules();
29
30 /**
31 * Unit test of {@code WMSImagery.WMSGetCapabilitiesException} class
32 */
33 @Test
34 public void testWMSGetCapabilitiesException() {
35 Exception cause = new Exception("test");
36 WMSGetCapabilitiesException exc = new WMSGetCapabilitiesException(cause, "bar");
37 assertEquals(cause, exc.getCause());
38 assertEquals("bar", exc.getIncomingData());
39 exc = new WMSGetCapabilitiesException("foo", "bar");
40 assertEquals("foo", exc.getMessage());
41 assertEquals("bar", exc.getIncomingData());
42 }
43
44 /**
45 * Non-regression test for bug #15730.
46 * @throws IOException if any I/O error occurs
47 * @throws WMSGetCapabilitiesException never
48 */
49 @Test
50 public void testTicket15730() throws IOException, WMSGetCapabilitiesException {
51 try (InputStream is = TestUtils.getRegressionDataStream(15730, "capabilities.xml")) {
52 WMSImagery wms = new WMSImagery();
53 wms.parseCapabilities(null, is);
54 assertEquals(1, wms.getLayers().size());
55 assertTrue(wms.getLayers().get(0).abstr.startsWith("South Carolina NAIP Imagery 2017 Resolution: 100CM "));
56 }
57 }
58
59 /**
60 * Non-regression test for bug #16248.
61 * @throws IOException if any I/O error occurs
62 * @throws WMSGetCapabilitiesException never
63 */
64 @Test
65 public void testTicket16248() throws IOException, WMSGetCapabilitiesException {
66 try (InputStream is = TestUtils.getRegressionDataStream(16248, "capabilities.xml")) {
67 WMSImagery wms = new WMSImagery();
68 wms.parseCapabilities(null, is);
69 assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k", wms.getServiceUrl().toExternalForm());
70 }
71 }
72}
Note: See TracBrowser for help on using the repository browser.