Ignore:
Timestamp:
2024-07-29T17:57:38+02:00 (9 months ago)
Author:
taylor.smock
Message:

Fix tests broken by r19152

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMSEndpointTileSourceTest.java

    r19052 r19155  
    1111import java.util.Collections;
    1212
     13import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
     14import org.junit.jupiter.api.BeforeEach;
    1315import org.junit.jupiter.api.Test;
    1416import org.openstreetmap.gui.jmapviewer.interfaces.TemplatedTileSource;
     
    2224import org.openstreetmap.josm.testutils.annotations.Projection;
    2325
    24 import com.github.tomakehurst.wiremock.WireMockServer;
    2526import com.github.tomakehurst.wiremock.client.WireMock;
    2627
     
    2930@Projection
    3031class WMSEndpointTileSourceTest implements TileSourceTest {
    31     @BasicWiremock
    32     WireMockServer tileServer;
     32    WireMockRuntimeInfo tileServer;
     33    @BeforeEach
     34    void setup(WireMockRuntimeInfo wireMockRuntimeInfo) {
     35        this.tileServer = wireMockRuntimeInfo;
     36    }
    3337
    3438    private void basicMock() {
    3539        final byte[] response = assertDoesNotThrow(() -> Files.readAllBytes(
    3640                Paths.get(TestUtils.getTestDataRoot() + "wms/geofabrik-osm-inspector.xml")));
    37         tileServer.stubFor(
     41        tileServer.getWireMock().register(
    3842                WireMock.get(WireMock.urlEqualTo("/capabilities?SERVICE=WMS&REQUEST=GetCapabilities"))
    3943                        .willReturn(WireMock.aResponse().withBody(response))
     
    4549        this.basicMock();
    4650        final ImageryInfo info = new ImageryInfo("WMSEndpointTileSourceTest");
    47         info.setExtendedUrl(tileServer.url("/capabilities"));
     51        info.setExtendedUrl(tileServer.getHttpBaseUrl() + "/capabilities");
    4852        info.setDefaultLayers(Collections.singletonList(new DefaultLayer(ImageryType.WMS_ENDPOINT,
    4953                "single_node_in_way", "default", null)));
     
    6064    void testDefaultLayerSetInMaps() throws Exception {
    6165
    62         tileServer.stubFor(
     66        tileServer.getWireMock().register(
    6367                WireMock.get(WireMock.urlEqualTo("/capabilities?SERVICE=WMS&REQUEST=GetCapabilities"))
    6468                .willReturn(
     
    6872                );
    6973
    70         tileServer.stubFor(WireMock.get(WireMock.urlEqualTo("/other/maps")).willReturn(WireMock.aResponse().withBody(
     74        tileServer.getWireMock().register(WireMock.get(WireMock.urlEqualTo("/other/maps")).willReturn(WireMock.aResponse().withBody(
    7175                "<?xml version='1.0' encoding='UTF-8'?>\n" +
    7276                "<imagery xmlns=\"http://josm.openstreetmap.de/maps-1.0\">\n" +
     
    7680                "<type>wms_endpoint</type>\n" +
    7781                "<category>qa</category>\n" +
    78                 "<url><![CDATA[" + tileServer.url("/capabilities") + "]]></url>\n" +
     82                "<url><![CDATA[" + tileServer.getHttpBaseUrl() + "/capabilities]]></url>\n" +
    7983                "<icon>data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsSAAALEgHS3X78AAAB5UlEQVQ4y4WTwWsTURDG" +
    8084                "fy8W1yYmXZOqtGJJFyGw6KF7CEigwYuS0kthrYUi4i0iORS9BU9hQdA/ILcixVBrwENKLz1FUBB0wWOwYFAqxUNYTZq6BfM8yC5d05iBObz3vfnmm3kz4sqDh/zP" +
     
    9599                )));
    96100
    97         Config.getPref().putList("imagery.layers.sites", Collections.singletonList(tileServer.url("/other/maps")));
     101        Config.getPref().putList("imagery.layers.sites", Collections.singletonList(tileServer.getHttpBaseUrl() + "/other/maps"));
    98102        ImageryLayerInfo.instance.loadDefaults(true, null, false);
    99103        assertEquals(1, ImageryLayerInfo.instance.getDefaultLayers().size());
     
    110114    @Test
    111115    void testCustomHeadersServerSide() throws IOException {
    112         tileServer.stubFor(
     116        tileServer.getWireMock().register(
    113117                WireMock.get(WireMock.urlEqualTo("/capabilities?SERVICE=WMS&REQUEST=GetCapabilities"))
    114118                .willReturn(
     
    118122                );
    119123
    120         tileServer.stubFor(WireMock.get(WireMock.urlEqualTo("/other/maps")).willReturn(WireMock.aResponse().withBody(
     124        tileServer.getWireMock().register(WireMock.get(WireMock.urlEqualTo("/other/maps")).willReturn(WireMock.aResponse().withBody(
    121125                "<?xml version='1.0' encoding='UTF-8'?>\n" +
    122126                "<imagery xmlns=\"http://josm.openstreetmap.de/maps-1.0\">\n" +
     
    129133                "        <country-code>NO</country-code>\n" +
    130134                "        <description lang=\"en\">Historic Norwegian orthophotos and maps, courtesy of Geovekst and Norkart.</description>\n" +
    131                 "        <url><![CDATA[" + tileServer.url("/capabilities?SERVICE=WMS&REQUEST=GetCapabilities") + "]]></url>\n" +
     135                "        <url><![CDATA[" + tileServer.getHttpBaseUrl() + "/capabilities?SERVICE=WMS&REQUEST=GetCapabilities]]></url>\n" +
    132136                "        <custom-http-header header-name=\"X-WAAPI-TOKEN\" header-value=\"b8e36d51-119a-423b-b156-d744d54123d5\" />\n" +
    133137                "        <attribution-text>© Geovekst</attribution-text>\n" +
     
    141145                )));
    142146
    143         Config.getPref().putList("imagery.layers.sites", Collections.singletonList(tileServer.url("/other/maps")));
     147        Config.getPref().putList("imagery.layers.sites", Collections.singletonList(tileServer.getHttpBaseUrl() + "/other/maps"));
    144148        ImageryLayerInfo.instance.loadDefaults(true, null, false);
    145149        ImageryInfo wmsImageryInfo = ImageryLayerInfo.instance.getDefaultLayers().get(0);
     
    150154        assertEquals("b8e36d51-119a-423b-b156-d744d54123d5", tileSource.getHeaders().get("X-WAAPI-TOKEN"));
    151155        assertTrue(wmsImageryInfo.isGeoreferenceValid());
    152         tileServer.verify(
     156        tileServer.getWireMock().verifyThat(
    153157                WireMock.getRequestedFor(WireMock.urlEqualTo("/capabilities?SERVICE=WMS&REQUEST=GetCapabilities"))
    154158                .withHeader("X-WAAPI-TOKEN", WireMock.equalTo("b8e36d51-119a-423b-b156-d744d54123d5")));
Note: See TracChangeset for help on using the changeset viewer.