source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/WMSLayerTest.java@ 17275

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

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertThrows;
6
7import org.junit.jupiter.api.Test;
8import org.junit.jupiter.api.extension.RegisterExtension;
9import org.openstreetmap.josm.data.imagery.ImageryInfo;
10import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
11import org.openstreetmap.josm.gui.MainApplication;
12import org.openstreetmap.josm.testutils.JOSMTestRules;
13
14import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15
16/**
17 * Unit tests of {@link WMSLayer} class.
18 */
19class 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}
Note: See TracBrowser for help on using the repository browser.