Changeset 18630 in josm for trunk/test/unit/org
- Timestamp:
- 2023-01-11T14:31:19+01:00 (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java
r18106 r18630 12 12 import org.junit.jupiter.api.Test; 13 13 import org.junit.jupiter.api.extension.RegisterExtension; 14 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; 14 15 import org.openstreetmap.josm.data.imagery.ImageryInfo; 15 16 import org.openstreetmap.josm.gui.MainApplication; … … 35 36 @RegisterExtension 36 37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 37 public JOSMTestRules test = new JOSMTestRules().fakeAPI() ;38 public JOSMTestRules test = new JOSMTestRules().fakeAPI().projection(); 38 39 39 40 /** … … 72 73 @Test 73 74 void testActionPerformedEnabledWms() { 74 wireMockServer.stubFor(get(urlEqualTo("/wms? SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1"))75 wireMockServer.stubFor(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1")) 75 76 .willReturn(aResponse() 76 77 .withStatus(200) 77 78 .withHeader("Content-Type", "text/xml") 78 79 .withBodyFile("imagery/wms-capabilities.xml"))); 79 wireMockServer.stubFor(get(urlEqualTo("/wms? SERVICE=WMS&REQUEST=GetCapabilities"))80 wireMockServer.stubFor(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities")) 80 81 .willReturn(aResponse() 81 82 .withStatus(404))); 82 wireMockServer.stubFor(get(urlEqualTo("/wms? SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0"))83 wireMockServer.stubFor(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0")) 83 84 .willReturn(aResponse() 84 85 .withStatus(404))); 85 86 86 new AddImageryLayerAction(new ImageryInfo("localhost", wireMockServer.url("/wms?"), 87 "wms_endpoint", null, null)).actionPerformed(null); 88 List<WMSLayer> wmsLayers = MainApplication.getLayerManager().getLayersOfType(WMSLayer.class); 89 assertEquals(1, wmsLayers.size()); 87 try { 88 FeatureAdapter.registerApiKeyAdapter(id -> "random_key"); 89 final ImageryInfo imageryInfo = new ImageryInfo("localhost", wireMockServer.url("/wms?apikey={apikey}"), 90 "wms_endpoint", null, null); 91 imageryInfo.setId("testActionPerformedEnabledWms"); 92 new AddImageryLayerAction(imageryInfo).actionPerformed(null); 93 List<WMSLayer> wmsLayers = MainApplication.getLayerManager().getLayersOfType(WMSLayer.class); 94 assertEquals(1, wmsLayers.size()); 90 95 91 MainApplication.getLayerManager().removeLayer(wmsLayers.get(0)); 96 MainApplication.getLayerManager().removeLayer(wmsLayers.get(0)); 97 } finally { 98 FeatureAdapter.registerApiKeyAdapter(new FeatureAdapter.DefaultApiKeyAdapter()); 99 } 92 100 } 93 101
Note:
See TracChangeset
for help on using the changeset viewer.