1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io.imagery;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertTrue;
|
---|
6 |
|
---|
7 | import java.io.IOException;
|
---|
8 | import java.io.InputStream;
|
---|
9 |
|
---|
10 | import org.junit.Rule;
|
---|
11 | import org.junit.Test;
|
---|
12 | import org.openstreetmap.josm.TestUtils;
|
---|
13 | import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException;
|
---|
14 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
15 |
|
---|
16 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Unit tests of {@link WMSImagery} class.
|
---|
20 | */
|
---|
21 | public 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 | }
|
---|