Changeset 19155 in josm for trunk/test/unit/org/openstreetmap/josm/actions
- Timestamp:
- 2024-07-29T17:57:38+02:00 (2 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/actions
- Files:
-
- 2 edited
-
AddImageryLayerActionTest.java (modified) (5 diffs)
-
downloadtasks/AbstractDownloadTaskTestParent.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java
r18870 r19155 10 10 import java.util.List; 11 11 12 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; 12 13 import org.junit.jupiter.api.Test; 13 14 import org.openstreetmap.gui.jmapviewer.FeatureAdapter; … … 21 22 import org.openstreetmap.josm.testutils.annotations.Projection; 22 23 23 import com.github.tomakehurst.wiremock.WireMockServer;24 25 24 /** 26 25 * Unit tests for class {@link AddImageryLayerAction}. … … 31 30 @Projection 32 31 final class AddImageryLayerActionTest { 33 /**34 * HTTP mock.35 */36 @BasicWiremock37 WireMockServer wireMockServer;38 39 32 /** 40 33 * Unit test of {@link AddImageryLayerAction#updateEnabledState}. … … 65 58 */ 66 59 @Test 67 void testActionPerformedEnabledWms() { 68 wireMock Server.stubFor(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1"))60 void testActionPerformedEnabledWms(WireMockRuntimeInfo wireMockRuntimeInfo) { 61 wireMockRuntimeInfo.getWireMock().register(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1")) 69 62 .willReturn(aResponse() 70 63 .withStatus(200) 71 64 .withHeader("Content-Type", "text/xml") 72 65 .withBodyFile("imagery/wms-capabilities.xml"))); 73 wireMock Server.stubFor(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities"))66 wireMockRuntimeInfo.getWireMock().register(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities")) 74 67 .willReturn(aResponse() 75 68 .withStatus(404))); 76 wireMock Server.stubFor(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0"))69 wireMockRuntimeInfo.getWireMock().register(get(urlEqualTo("/wms?apikey=random_key&SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.3.0")) 77 70 .willReturn(aResponse() 78 71 .withStatus(404))); … … 80 73 try { 81 74 FeatureAdapter.registerApiKeyAdapter(id -> "random_key"); 82 final ImageryInfo imageryInfo = new ImageryInfo("localhost", wireMock Server.url("/wms?apikey={apikey}"),75 final ImageryInfo imageryInfo = new ImageryInfo("localhost", wireMockRuntimeInfo.getHttpBaseUrl() + "/wms?apikey={apikey}", 83 76 "wms_endpoint", null, null); 84 77 imageryInfo.setId("testActionPerformedEnabledWms"); -
trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTaskTestParent.java
r18893 r19155 6 6 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; 7 7 8 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; 9 import org.junit.jupiter.api.BeforeEach; 8 10 import org.openstreetmap.josm.testutils.annotations.BasicWiremock; 9 11 import org.openstreetmap.josm.testutils.annotations.HTTPS; 10 11 import com.github.tomakehurst.wiremock.WireMockServer;12 12 13 13 /** … … 17 17 @HTTPS 18 18 public abstract class AbstractDownloadTaskTestParent { 19 /**20 * HTTP mock.21 */22 @BasicWiremock23 WireMockServer wireMockServer;19 WireMockRuntimeInfo wireMockServer; 20 @BeforeEach 21 void setup(WireMockRuntimeInfo wireMockRuntimeInfo) { 22 this.wireMockServer = wireMockRuntimeInfo; 23 } 24 24 25 25 /** … … 43 43 */ 44 44 protected final String getRemoteFileUrl() { 45 return wireMockServer.url(getRemoteFile()); 45 final String remote = getRemoteFile(); 46 if (remote.startsWith("/")) { 47 return wireMockServer.getHttpBaseUrl() + getRemoteFile(); 48 } 49 return wireMockServer.getHttpBaseUrl() + '/' + getRemoteFile(); 46 50 } 47 51 … … 50 54 */ 51 55 protected final void mockHttp() { 52 wireMockServer. stubFor(get(urlEqualTo("/" + getRemoteFile()))56 wireMockServer.getWireMock().register(get(urlEqualTo("/" + getRemoteFile())) 53 57 .willReturn(aResponse() 54 58 .withStatus(200)
Note:
See TracChangeset
for help on using the changeset viewer.
