1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
---|
6 |
|
---|
7 | import org.junit.jupiter.api.Test;
|
---|
8 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
9 | import org.openstreetmap.josm.data.imagery.ImageryInfo;
|
---|
10 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
|
---|
11 | import org.openstreetmap.josm.gui.MainApplication;
|
---|
12 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
13 |
|
---|
14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Unit tests of {@link WMSLayer} class.
|
---|
18 | */
|
---|
19 | class WMSLayerTest {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Setup tests
|
---|
23 | */
|
---|
24 | @RegisterExtension
|
---|
25 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
26 | public JOSMTestRules test = new JOSMTestRules().main().projection();
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Unit test of {@link WMSLayer#WMSLayer}.
|
---|
30 | */
|
---|
31 | @Test
|
---|
32 | void testWMSLayer() {
|
---|
33 | WMSLayer wms = new WMSLayer(new ImageryInfo("test wms", "http://localhost"));
|
---|
34 | MainApplication.getLayerManager().addLayer(wms);
|
---|
35 | try {
|
---|
36 | assertEquals(ImageryType.WMS, wms.getInfo().getImageryType());
|
---|
37 | } finally {
|
---|
38 | // Ensure we clean the place before leaving, even if test fails.
|
---|
39 | MainApplication.getLayerManager().removeLayer(wms);
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/13828">Bug #13828</a>.
|
---|
45 | */
|
---|
46 | @Test
|
---|
47 | void testTicket13828() {
|
---|
48 | assertThrows(IllegalArgumentException.class, () -> new WMSLayer(new ImageryInfo("TMS", "http://203.159.29.217/try2/{z}/{x}/{y}.png")));
|
---|
49 | }
|
---|
50 | }
|
---|