Changeset 19155 in josm


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

Fix tests broken by r19152

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/AddImageryLayerActionTest.java

    r18870 r19155  
    1010import java.util.List;
    1111
     12import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    1213import org.junit.jupiter.api.Test;
    1314import org.openstreetmap.gui.jmapviewer.FeatureAdapter;
     
    2122import org.openstreetmap.josm.testutils.annotations.Projection;
    2223
    23 import com.github.tomakehurst.wiremock.WireMockServer;
    24 
    2524/**
    2625 * Unit tests for class {@link AddImageryLayerAction}.
     
    3130@Projection
    3231final class AddImageryLayerActionTest {
    33     /**
    34      * HTTP mock.
    35      */
    36     @BasicWiremock
    37     WireMockServer wireMockServer;
    38 
    3932    /**
    4033     * Unit test of {@link AddImageryLayerAction#updateEnabledState}.
     
    6558     */
    6659    @Test
    67     void testActionPerformedEnabledWms() {
    68         wireMockServer.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"))
    6962                .willReturn(aResponse()
    7063                        .withStatus(200)
    7164                        .withHeader("Content-Type", "text/xml")
    7265                        .withBodyFile("imagery/wms-capabilities.xml")));
    73         wireMockServer.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"))
    7467                .willReturn(aResponse()
    7568                        .withStatus(404)));
    76         wireMockServer.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"))
    7770                .willReturn(aResponse()
    7871                        .withStatus(404)));
     
    8073        try {
    8174            FeatureAdapter.registerApiKeyAdapter(id -> "random_key");
    82             final ImageryInfo imageryInfo = new ImageryInfo("localhost", wireMockServer.url("/wms?apikey={apikey}"),
     75            final ImageryInfo imageryInfo = new ImageryInfo("localhost", wireMockRuntimeInfo.getHttpBaseUrl() + "/wms?apikey={apikey}",
    8376                    "wms_endpoint", null, null);
    8477            imageryInfo.setId("testActionPerformedEnabledWms");
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTaskTestParent.java

    r18893 r19155  
    66import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
    77
     8import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
     9import org.junit.jupiter.api.BeforeEach;
    810import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
    911import org.openstreetmap.josm.testutils.annotations.HTTPS;
    10 
    11 import com.github.tomakehurst.wiremock.WireMockServer;
    1212
    1313/**
     
    1717@HTTPS
    1818public abstract class AbstractDownloadTaskTestParent {
    19     /**
    20      * HTTP mock.
    21      */
    22     @BasicWiremock
    23     WireMockServer wireMockServer;
     19    WireMockRuntimeInfo wireMockServer;
     20    @BeforeEach
     21    void setup(WireMockRuntimeInfo wireMockRuntimeInfo) {
     22        this.wireMockServer = wireMockRuntimeInfo;
     23    }
    2424
    2525    /**
     
    4343     */
    4444    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();
    4650    }
    4751
     
    5054     */
    5155    protected final void mockHttp() {
    52         wireMockServer.stubFor(get(urlEqualTo("/" + getRemoteFile()))
     56        wireMockServer.getWireMock().register(get(urlEqualTo("/" + getRemoteFile()))
    5357                .willReturn(aResponse()
    5458                    .withStatus(200)
  • trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java

    r19050 r19155  
    2121import java.util.concurrent.TimeUnit;
    2222
     23import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    2324import org.apache.commons.jcs3.access.behavior.ICacheAccess;
    2425import org.apache.commons.jcs3.engine.behavior.ICacheElement;
     
    3334import org.openstreetmap.josm.tools.Logging;
    3435
    35 import com.github.tomakehurst.wiremock.WireMockServer;
    3636import com.github.tomakehurst.wiremock.matching.UrlPattern;
    3737
     
    4747     * mocked tile server
    4848     */
    49     @BasicWiremock
    50     WireMockServer tileServer;
     49    WireMockRuntimeInfo tileServer;
    5150
    5251    private static class TestCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, CacheEntry> {
     
    105104    /**
    106105     * Always clear cache before tests
    107      * @throws Exception when clearing fails
    108106     */
    109107    @BeforeEach
    110     void clearCache() throws Exception {
     108    void clearCache() {
    111109        getCache().clear();
    112110    }
    113111
     112    @BeforeEach
     113    void setup(WireMockRuntimeInfo wireMockRuntimeInfo) {
     114        this.tileServer = wireMockRuntimeInfo;
     115    }
     116
    114117    /**
    115118     * Test status codes
    116      * @throws InterruptedException in case of thread interruption
    117119     * @throws IOException in case of I/O error
    118120     */
    119121    @Test
    120     void testStatusCodes() throws IOException, InterruptedException {
     122    void testStatusCodes() throws IOException {
    121123        doTestStatusCode(200);
    122124        doTestStatusCode(401);
     
    155157
    156158    private void doTestStatusCode(int responseCode) throws IOException {
    157         tileServer.stubFor(get(urlEqualTo("/httpstat/" + responseCode)).willReturn(aResponse().withStatus(responseCode)));
     159        tileServer.getWireMock().register(get(urlEqualTo("/httpstat/" + responseCode)).willReturn(aResponse().withStatus(responseCode)));
    158160        TestCachedTileLoaderJob job = getStatusLoaderJob(responseCode);
    159161        Listener listener = submitJob(job);
     
    196198        createHeadGetStub(urlEqualTo("/test"), expires, testStart, "eTag", "mock entry");
    197199
    198         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
    199         Listener listener = submitJob(job, false);
    200         tileServer.verify(0, getRequestedFor(anyUrl()));
     200        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test");
     201        Listener listener = submitJob(job, false);
     202        tileServer.getWireMock().verifyThat(0, getRequestedFor(anyUrl()));
    201203        assertArrayEquals("cached entry".getBytes(StandardCharsets.UTF_8), listener.data);
    202204    }
     
    217219        createHeadGetStub(urlEqualTo("/test"), expires, testStart, "eTag", "mock entry");
    218220
    219         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
     221        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test");
    220222        Listener listener = submitJob(job, true);
    221         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     223        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    222224        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    223225    }
     
    231233    void testSettingMinimumExpiryWhenNoExpires() throws IOException {
    232234        long testStart = System.currentTimeMillis();
    233         tileServer.stubFor(get(urlEqualTo("/test")).willReturn(aResponse().withBody("mock entry")));
    234 
    235         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
    236         Listener listener = submitJob(job, false);
    237         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     235        tileServer.getWireMock().register(get(urlEqualTo("/test")).willReturn(aResponse().withBody("mock entry")));
     236
     237        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test");
     238        Listener listener = submitJob(job, false);
     239        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    238240
    239241        assertTrue(listener.attributes.getExpirationTime() >= testStart + JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME,
     
    260262        long testStart = System.currentTimeMillis();
    261263        long expires = TimeUnit.DAYS.toSeconds(1);
    262         tileServer.stubFor(get(urlEqualTo("/test"))
     264        tileServer.getWireMock().register(get(urlEqualTo("/test"))
    263265                .willReturn(aResponse()
    264266                        .withHeader("Cache-control", "max-age=" + expires)
     
    267269                );
    268270
    269         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
    270         Listener listener = submitJob(job, false);
    271         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     271        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test");
     272        Listener listener = submitJob(job, false);
     273        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    272274
    273275        assertTrue(listener.attributes.getExpirationTime() >= testStart + TimeUnit.SECONDS.toMillis(expires),
     
    298300        createHeadGetStub(urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
    299301
    300         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
    301         Listener listener = submitJob(job, false);
    302         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     302        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test", minimumExpiryTimeSeconds);
     303        Listener listener = submitJob(job, false);
     304        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    303305        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    304306
     
    331333        createHeadGetStub(urlEqualTo("/test"), (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10), testStart, "eTag", "mock entry");
    332334
    333         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
    334         Listener listener = submitJob(job, false);
    335         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     335        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test", minimumExpiryTimeSeconds);
     336        Listener listener = submitJob(job, false);
     337        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    336338        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    337339
     
    367369        int minimumExpiryTimeSeconds = 0;
    368370
    369         tileServer.stubFor(get(urlEqualTo("/test"))
     371        tileServer.getWireMock().register(get(urlEqualTo("/test"))
    370372                .willReturn(aResponse()
    371373                        .withHeader("Expires", TestUtils.getHTTPDate(testStart + (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10)))
     
    375377                        )
    376378                );
    377         tileServer.stubFor(head(urlEqualTo("/test"))
     379        tileServer.getWireMock().register(head(urlEqualTo("/test"))
    378380                .willReturn(aResponse()
    379381                        .withHeader("Expires", TestUtils.getHTTPDate(testStart + (JCSCachedTileLoaderJob.DEFAULT_EXPIRE_TIME / 10)))
     
    382384                        )
    383385                );
    384         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
    385         Listener listener = submitJob(job, false);
    386         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     386        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test", minimumExpiryTimeSeconds);
     387        Listener listener = submitJob(job, false);
     388        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    387389        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    388390
     
    413415        int minimumExpiryTimeSeconds = 0;
    414416
    415         tileServer.stubFor(get(urlEqualTo("/test"))
     417        tileServer.getWireMock().register(get(urlEqualTo("/test"))
    416418                .willReturn(aResponse()
    417419                        .withHeader("Cache-Control", "" +
     
    422424                        )
    423425                );
    424         tileServer.stubFor(head(urlEqualTo("/test"))
     426        tileServer.getWireMock().register(head(urlEqualTo("/test"))
    425427                .willReturn(aResponse()
    426428                        .withHeader("Cache-Control", "" +
     
    429431                        )
    430432                ));
    431         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test", minimumExpiryTimeSeconds);
    432         Listener listener = submitJob(job, false);
    433         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     433        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test", minimumExpiryTimeSeconds);
     434        Listener listener = submitJob(job, false);
     435        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    434436        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    435437
     
    461463                );
    462464
    463         tileServer.stubFor(get(urlEqualTo("/test"))
     465        tileServer.getWireMock().register(get(urlEqualTo("/test"))
    464466                .willReturn(aResponse()
    465467                        .withHeader("Expires", TestUtils.getHTTPDate(testStart + expires))
     
    469471                        )
    470472                );
    471         tileServer.stubFor(head(urlEqualTo("/test"))
     473        tileServer.getWireMock().register(head(urlEqualTo("/test"))
    472474                .willReturn(aResponse()
    473475                        .withHeader("Expires", TestUtils.getHTTPDate(testStart + expires))
     
    477479                );
    478480
    479         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
     481        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test");
    480482        Listener listener = submitJob(job, false); // cache entry is expired, no need to force refetch
    481         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     483        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    482484        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    483485
    484486        // cache entry should be retrieved from cache
    485487        listener = submitJob(job, false);
    486         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     488        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    487489        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    488490
     
    494496
    495497        // because cache entry is invalid - HEAD request shall be made
    496         tileServer.verify(0, headRequestedFor(urlEqualTo("/test"))); // no head requests were made until now
     498        tileServer.getWireMock().verifyThat(0, headRequestedFor(urlEqualTo("/test"))); // no head requests were made until now
    497499        listener = submitJob(job, false);
    498         tileServer.verify(1, headRequestedFor(urlEqualTo("/test"))); // verify head requests were made
    499         tileServer.verify(1, getRequestedFor(urlEqualTo("/test"))); // verify no more get requests were made
     500        tileServer.getWireMock().verifyThat(1, headRequestedFor(urlEqualTo("/test"))); // verify head requests were made
     501        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test"))); // verify no more get requests were made
    500502        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    501503        assertTrue(listener.attributes.getExpirationTime() >= testStart + expires);
     
    503505        // cache entry should be retrieved from cache
    504506        listener = submitJob(job, false); // cache entry is expired, no need to force refetch
    505         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
    506         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     507        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
     508        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    507509        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), listener.data);
    508510    }
     
    522524                );
    523525
    524         tileServer.stubFor(get(urlEqualTo("/test"))
     526        tileServer.getWireMock().register(get(urlEqualTo("/test"))
    525527                .willReturn(status(304)
    526528                        .withHeader("Expires", TestUtils.getHTTPDate(testStart + expires))
     
    530532                );
    531533
    532         TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.url("/test"), "test");
    533         Listener listener = submitJob(job, false);
    534         tileServer.verify(1, getRequestedFor(urlEqualTo("/test")));
     534        TestCachedTileLoaderJob job = new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/test", "test");
     535        Listener listener = submitJob(job, false);
     536        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test")));
    535537        assertArrayEquals("cached dummy".getBytes(StandardCharsets.UTF_8), listener.data);
    536538        assertTrue(testStart + expires <= listener.attributes.getExpirationTime());
    537539        submitJob(job, false);
    538         tileServer.verify(1, getRequestedFor(urlEqualTo("/test"))); // no more requests were made
     540        tileServer.getWireMock().verifyThat(1, getRequestedFor(urlEqualTo("/test"))); // no more requests were made
    539541    }
    540542
    541543    private void createHeadGetStub(UrlPattern url, long expires, long lastModified, String eTag, String body) {
    542         tileServer.stubFor(get(url)
     544        tileServer.getWireMock().register(get(url)
    543545                .willReturn(aResponse()
    544546                        .withHeader("Expires", TestUtils.getHTTPDate(lastModified + expires))
     
    548550                        )
    549551                );
    550         tileServer.stubFor(head(url)
     552        tileServer.getWireMock().register(head(url)
    551553                .willReturn(aResponse()
    552554                        .withHeader("Expires", TestUtils.getHTTPDate(lastModified + expires))
     
    567569
    568570    private TestCachedTileLoaderJob getStatusLoaderJob(int responseCode) {
    569         return new TestCachedTileLoaderJob(tileServer.url("/httpstat/" + responseCode), "key_" + responseCode);
     571        return new TestCachedTileLoaderJob(tileServer.getHttpBaseUrl() + "/httpstat/" + responseCode, "key_" + responseCode);
    570572    }
    571573
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java

    r19050 r19155  
    1616import java.util.regex.Pattern;
    1717
     18import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    1819import org.apache.commons.jcs3.access.behavior.ICacheAccess;
    1920import org.junit.jupiter.api.BeforeEach;
     
    3132import org.openstreetmap.josm.tools.Utils;
    3233
    33 import com.github.tomakehurst.wiremock.WireMockServer;
    3434import com.github.tomakehurst.wiremock.client.WireMock;
    3535
     
    4343     * mocked tile server
    4444     */
    45     @BasicWiremock
    46     WireMockServer tileServer;
     45    private WireMockRuntimeInfo wireMockRuntimeInfo;
    4746
    4847    @BeforeEach
    49     void clearCache() throws Exception {
     48    void clearCache() {
    5049        getCache().clear();
     50    }
     51
     52    @BeforeEach
     53    void setup(WireMockRuntimeInfo wireMockRuntimeInfo) {
     54        this.wireMockRuntimeInfo = wireMockRuntimeInfo;
    5155    }
    5256
     
    126130
    127131        @Override
    128         public String getTileUrl(int zoom, int tilex, int tiley) throws IOException {
     132        public String getTileUrl(int zoom, int tilex, int tiley) {
    129133            return url;
    130134        }
     
    219223    void testNoCacheHeaders() throws IOException {
    220224        long testStart = System.currentTimeMillis();
    221         tileServer.stubFor(
     225        wireMockRuntimeInfo.getWireMock().register(
    222226                WireMock.get(WireMock.urlEqualTo("/test"))
    223227                .willReturn(WireMock.aResponse()
     
    226230                );
    227231
    228         TestCachedTileLoaderJob job = submitJob(new MockTile(tileServer.url("/test")), "test", false);
     232        TestCachedTileLoaderJob job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", false);
    229233        assertExpirationAtLeast(testStart + TMSCachedTileLoaderJob.MINIMUM_EXPIRES.get(), job);
    230234        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    231         job = submitJob(new MockTile(tileServer.url("/test")), "test", false); // submit another job for the same tile
     235        job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", false); // submit another job for the same tile
    232236        // only one request to tile server should be made, second should come from cache
    233         tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
     237        wireMockRuntimeInfo.getWireMock().verifyThat(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
    234238        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    235239    }
     
    257261    private void noCacheHeadersMinimumExpires(int minimumExpires) throws IOException {
    258262        long testStart = System.currentTimeMillis();
    259         tileServer.stubFor(
     263        wireMockRuntimeInfo.getWireMock().register(
    260264                WireMock.get(WireMock.urlEqualTo("/test"))
    261265                .willReturn(WireMock.aResponse()
     
    263267                        )
    264268                );
    265         TestCachedTileLoaderJob job = submitJob(new MockTile(tileServer.url("/test")), "test", minimumExpires, false);
     269        TestCachedTileLoaderJob job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", minimumExpires, false);
    266270        assertExpirationAtLeast(testStart + minimumExpires, job);
    267271        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    268         job = submitJob(new MockTile(tileServer.url("/test")), "test", false); // submit another job for the same tile
     272        job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", false); // submit another job for the same tile
    269273        // only one request to tile server should be made, second should come from cache
    270         tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
     274        wireMockRuntimeInfo.getWireMock().verifyThat(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
    271275        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    272276    }
     
    280284        long testStart = System.currentTimeMillis();
    281285        long expires = TMSCachedTileLoaderJob.MINIMUM_EXPIRES.get() / 2;
    282         tileServer.stubFor(
     286        wireMockRuntimeInfo.getWireMock().register(
    283287                WireMock.get(WireMock.urlEqualTo("/test"))
    284288                .willReturn(WireMock.aResponse()
     
    287291                        )
    288292                );
    289         TestCachedTileLoaderJob job = submitJob(new MockTile(tileServer.url("/test")), "test", false);
     293        TestCachedTileLoaderJob job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", false);
    290294        assertExpirationAtLeast(testStart + TMSCachedTileLoaderJob.MINIMUM_EXPIRES.get(), job);
    291295        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    292         job = submitJob(new MockTile(tileServer.url("/test")), "test", false); // submit another job for the same tile
     296        job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", false); // submit another job for the same tile
    293297        // only one request to tile server should be made, second should come from cache
    294         tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
     298        wireMockRuntimeInfo.getWireMock().verifyThat(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
    295299        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    296300    }
     
    312316        long testStart = System.currentTimeMillis();
    313317        long expires = TMSCachedTileLoaderJob.MAXIMUM_EXPIRES.get() * 2;
    314         tileServer.stubFor(
     318        wireMockRuntimeInfo.getWireMock().register(
    315319                WireMock.get(WireMock.urlEqualTo("/test"))
    316320                .willReturn(WireMock.aResponse()
     
    319323                        )
    320324                );
    321         TestCachedTileLoaderJob job = submitJob(new MockTile(tileServer.url("/test")), "test", false);
     325        TestCachedTileLoaderJob job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", false);
    322326        // give 1 second margin
    323327        assertExpirationAtMost(testStart + TMSCachedTileLoaderJob.MAXIMUM_EXPIRES.get() + TimeUnit.SECONDS.toMillis(1), job);
    324328
    325329        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    326         job = submitJob(new MockTile(tileServer.url("/test")), "test", false); // submit another job for the same tile
     330        job = submitJob(new MockTile(wireMockRuntimeInfo.getHttpBaseUrl() + "/test"), "test", false); // submit another job for the same tile
    327331        // only one request to tile server should be made, second should come from cache
    328         tileServer.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
     332        wireMockRuntimeInfo.getWireMock().verifyThat(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/test")));
    329333        assertArrayEquals("mock entry".getBytes(StandardCharsets.UTF_8), job.get().getContent());
    330334    }
  • 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")));
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java

    r19077 r19155  
    2323import java.util.concurrent.TimeUnit;
    2424
     25import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    2526import org.junit.jupiter.api.Disabled;
    2627import org.junit.jupiter.api.Test;
     
    4546import org.openstreetmap.josm.tools.ReflectionUtils;
    4647
    47 import com.github.tomakehurst.wiremock.WireMockServer;
    4848import com.github.tomakehurst.wiremock.client.WireMock;
    4949
     
    5656@Timeout(value = 5, unit = TimeUnit.MINUTES)
    5757class WMTSTileSourceTest {
    58     @BasicWiremock
    59     WireMockServer tileServer;
    60 
    6158    private final ImageryInfo testImageryTMS = new ImageryInfo("test imagery", "http://localhost", "tms", null, null);
    6259    private final ImageryInfo testImageryPSEUDO_MERCATOR = getImagery(TestUtils.getTestDataRoot() + "wmts/getcapabilities-pseudo-mercator.xml");
     
    367364
    368365    @Test
    369     void testDefaultLayer() throws Exception {
     366    void testDefaultLayer(WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {
    370367        // https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/1.0.0/WMTSCapabilities.xml
    371368        // do not use withFileBody as it needs different directory layout :(
    372369
    373         tileServer.stubFor(
     370        wireMockRuntimeInfo.getWireMock().register(
    374371                WireMock.get("/getcapabilities.xml")
    375372                .willReturn(
     
    381378                );
    382379
    383         tileServer.stubFor(
     380        wireMockRuntimeInfo.getWireMock().register(
    384381                WireMock.get("/other/maps")
    385382                .willReturn(
     
    392389                "<type>wmts</type>\n" +
    393390                "<category>photo</category>\n" +
    394                 "<url><![CDATA[" + tileServer.url("/getcapabilities.xml") + "]]></url>\n" +
     391                "<url><![CDATA[" + wireMockRuntimeInfo.getHttpBaseUrl() + "/getcapabilities.xml]]></url>\n" +
    395392                "<default-layers>" +
    396393                "<layer name=\"GEOGRAPHICALGRIDSYSTEMS.MAPS\" />" +
     
    400397                )));
    401398
    402         Config.getPref().putList("imagery.layers.sites", Collections.singletonList(tileServer.url("/other/maps")));
     399        Config.getPref().putList("imagery.layers.sites", Collections.singletonList(wireMockRuntimeInfo.getHttpBaseUrl() + "/other/maps"));
    403400        ImageryLayerInfo.instance.loadDefaults(true, null, false);
    404401
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DefaultNameFormatterTest.java

    r18977 r19155  
    1515import java.util.stream.IntStream;
    1616
     17import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    1718import org.junit.jupiter.api.Test;
    1819import org.openstreetmap.josm.TestUtils;
     
    2526import org.openstreetmap.josm.testutils.annotations.HTTP;
    2627import org.xml.sax.SAXException;
    27 
    28 import com.github.tomakehurst.wiremock.WireMockServer;
    2928
    3029import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    3938class DefaultNameFormatterTest {
    4039    /**
    41      * HTTP mock.
    42      */
    43     @BasicWiremock
    44     WireMockServer wireMockServer;
    45 
    46     /**
    4740     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/9632">#9632</a>.
     41     * @param wireMockRuntimeInfo Wiremock information
    4842     * @throws IllegalDataException if an error was found while parsing the data from the source
    4943     * @throws IOException if any I/O error occurs
     
    5246    @Test
    5347    @SuppressFBWarnings(value = "ITA_INEFFICIENT_TO_ARRAY")
    54     void testTicket9632() throws IllegalDataException, IOException, SAXException {
     48    void testTicket9632(WireMockRuntimeInfo wireMockRuntimeInfo) throws IllegalDataException, IOException, SAXException {
    5549        String source = "presets/Presets_BicycleJunction-preset.xml";
    56         wireMockServer.stubFor(get(urlEqualTo("/" + source))
     50        wireMockRuntimeInfo.getWireMock().register(get(urlEqualTo("/" + source))
    5751                .willReturn(aResponse()
    5852                    .withStatus(200)
    5953                    .withHeader("Content-Type", "text/xml")
    6054                    .withBodyFile(source)));
    61         TaggingPresets.addTaggingPresets(TaggingPresetReader.readAll(wireMockServer.url(source), true));
     55        TaggingPresets.addTaggingPresets(TaggingPresetReader.readAll(wireMockRuntimeInfo.getHttpBaseUrl() + '/' + source, true));
    6256
    6357        Comparator<IRelation<?>> comparator = DefaultNameFormatter.getInstance().getRelationComparator();
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/server/ApiUrlTestTaskTest.java

    r18106 r19155  
    1414import java.awt.Component;
    1515
     16import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
     17import org.junit.jupiter.api.BeforeEach;
    1618import org.junit.jupiter.api.Test;
    1719import org.junit.jupiter.api.Timeout;
     
    2022import org.openstreetmap.josm.testutils.annotations.HTTP;
    2123import org.openstreetmap.josm.tools.Logging;
    22 
    23 import com.github.tomakehurst.wiremock.WireMockServer;
    2424
    2525/**
     
    3131@HTTP
    3232class ApiUrlTestTaskTest {
    33     /**
    34      * HTTP mock.
    35      */
    36     @BasicWiremock
    37     WireMockServer wireMockServer;
     33    private WireMockRuntimeInfo wireMockServer;
     34
    3835
    3936    private static final Component PARENT = new JLabel();
     37
     38    @BeforeEach
     39    void setup(WireMockRuntimeInfo wireMockServer) {
     40        this.wireMockServer = wireMockServer;
     41    }
    4042
    4143    /**
     
    5254    @Test
    5355    void testNominalUrl() {
    54         ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockServer.url("/__files/api"));
     56        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockServer.getHttpBaseUrl() + "/__files/api");
    5557        task.run();
    5658        assertTrue(task.isSuccess());
     
    8991    void testAlertInvalidServerResult() {
    9092        Logging.clearLastErrorAndWarnings();
    91         wireMockServer.stubFor(get(urlEqualTo("/does-not-exist/0.6/capabilities"))
     93        wireMockServer.getWireMock().register(get(urlEqualTo("/does-not-exist/0.6/capabilities"))
    9294                .willReturn(aResponse().withStatus(404)));
    9395
    94         ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockServer.url("/does-not-exist"));
     96        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockServer.getHttpBaseUrl() + "/does-not-exist");
    9597        task.run();
    9698        assertFalse(task.isSuccess());
     
    105107    void testAlertInvalidCapabilities() {
    106108        Logging.clearLastErrorAndWarnings();
    107         ApiUrlTestTask task = new ApiUrlTestTask(PARENT, wireMockServer.url("/__files/invalid_api"));
     109        final String url = wireMockServer.getHttpBaseUrl() + "/__files/invalid_api";
     110        ApiUrlTestTask task = new ApiUrlTestTask(PARENT, url);
    108111        task.run();
    109112        assertFalse(task.isSuccess());
    110113        assertThat(Logging.getLastErrorAndWarnings().toString(), containsString(
    111114                "The OSM API server at 'XXX' did not return a valid response.<br>It is likely that 'XXX' is not an OSM API server."
    112                         .replace("XXX", wireMockServer.url("/__files/invalid_api"))));
     115                        .replace("XXX", url)));
    113116    }
    114117}
  • trunk/test/unit/org/openstreetmap/josm/io/OsmServerHistoryReaderTest.java

    r18106 r19155  
    66import java.time.Instant;
    77
     8import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    89import org.junit.jupiter.api.BeforeEach;
    910import org.junit.jupiter.api.Test;
     
    1718import org.openstreetmap.josm.testutils.annotations.HTTP;
    1819
    19 import com.github.tomakehurst.wiremock.WireMockServer;
    20 
    2120/**
    2221 * Unit tests of {@link OsmServerHistoryReader} class.
     
    2726class OsmServerHistoryReaderTest {
    2827    /**
    29      * HTTP mock.
    30      */
    31     @BasicWiremock
    32     WireMockServer wireMockServer;
    33 
    34     /**
    3528     * Setup tests.
    3629     */
    3730    @BeforeEach
    38     void setUp() {
    39         Config.getPref().put("osm-server.url", wireMockServer.url("/__files/api"));
     31    void setUp(WireMockRuntimeInfo wireMockRuntimeInfo) {
     32        Config.getPref().put("osm-server.url", wireMockRuntimeInfo.getHttpBaseUrl() + "/__files/api");
    4033    }
    4134
  • trunk/test/unit/org/openstreetmap/josm/io/OverpassDownloadReaderTest.java

    r18106 r19155  
    1414import java.util.regex.Matcher;
    1515
     16import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    1617import org.junit.jupiter.api.BeforeEach;
    1718import org.junit.jupiter.api.Test;
     
    2526import org.openstreetmap.josm.tools.date.DateUtils;
    2627
    27 import com.github.tomakehurst.wiremock.WireMockServer;
    28 
    2928/**
    3029 * Unit tests of {@link OverpassDownloadReader} class.
     
    3433@HTTP
    3534class OverpassDownloadReaderTest {
    36     /**
    37      * HTTP mock.
    38      */
    39     @BasicWiremock
    40     WireMockServer wireMockServer;
     35    private WireMockRuntimeInfo wireMockServer;
    4136
    4237    private static final String NOMINATIM_URL_PATH = "/search?format=xml&q=";
     
    4641     */
    4742    @BeforeEach
    48     public void setUp() {
    49         NameFinder.NOMINATIM_URL_PROP.put(wireMockServer.url(NOMINATIM_URL_PATH));
     43    public void setUp(WireMockRuntimeInfo wireMockRuntimeInfo) {
     44        this.wireMockServer = wireMockRuntimeInfo;
     45        NameFinder.NOMINATIM_URL_PROP.put(wireMockServer.getHttpBaseUrl() + NOMINATIM_URL_PATH);
    5046    }
    5147
     
    7470
    7571    private void stubNominatim(String query) {
    76         wireMockServer.stubFor(get(urlEqualTo(NOMINATIM_URL_PATH + query))
     72        wireMockServer.getWireMock().register(get(urlEqualTo(NOMINATIM_URL_PATH + query))
    7773                .willReturn(aResponse()
    7874                    .withStatus(200)
  • trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java

    r18870 r19155  
    1111import java.util.List;
    1212
     13import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
     14import org.junit.jupiter.api.BeforeEach;
    1315import org.junit.jupiter.api.Test;
    1416import org.openstreetmap.josm.TestUtils;
     
    1820import org.openstreetmap.josm.testutils.annotations.Projection;
    1921
    20 import com.github.tomakehurst.wiremock.WireMockServer;
    2122import com.github.tomakehurst.wiremock.client.WireMock;
    2223
     
    2829@Projection
    2930class WMSImageryTest {
    30     @BasicWiremock
    31     WireMockServer tileServer;
     31
     32    private WireMockRuntimeInfo tileServer;
     33
     34    @BeforeEach
     35    void setup(WireMockRuntimeInfo wireMockRuntimeRule) {
     36        this.tileServer = wireMockRuntimeRule;
     37    }
    3238
    3339    /**
     
    5258    @Test
    5359    void testTicket15730() throws IOException, WMSGetCapabilitiesException {
    54         tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(
     60        tileServer.getWireMock().register(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(
    5561                Files.readAllBytes(Paths.get(TestUtils.getRegressionDataDir(15730), "capabilities.xml"))
    5662                )));
    5763
    58         WMSImagery wms = new WMSImagery(tileServer.url("capabilities.xml"));
     64        WMSImagery wms = new WMSImagery(tileServer.getHttpBaseUrl() + "/capabilities.xml");
    5965        assertEquals(1, wms.getLayers().size());
    6066        assertTrue(wms.getLayers().get(0).getAbstract().startsWith("South Carolina  NAIP Imagery 2017    Resolution: 100CM "));
     
    6369    @Test
    6470    void testNestedLayers() throws Exception {
    65         tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(
     71        tileServer.getWireMock().register(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(
    6672                Files.readAllBytes(Paths.get(TestUtils.getTestDataRoot() + "wms/mapa-um-warszawa-pl.xml")))));
    67         WMSImagery wmsi = new WMSImagery(tileServer.url("/serwis"));
     73        WMSImagery wmsi = new WMSImagery(tileServer.getHttpBaseUrl() + "/serwis");
    6874        assertEquals(1, wmsi.getLayers().size());
    6975        assertEquals("Server WMS m.st. Warszawy", wmsi.getLayers().get(0).toString());
     
    7985    void testTicket16248() throws IOException, WMSGetCapabilitiesException {
    8086        byte[] capabilities = Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(16248, "capabilities.xml")));
    81         tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(capabilities)));
    82         WMSImagery wms = new WMSImagery(tileServer.url("any"));
     87        tileServer.getWireMock().register(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(capabilities)));
     88        WMSImagery wms = new WMSImagery(tileServer.getHttpBaseUrl() + "/any");
    8389        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k?", wms.buildRootUrl());
    8490        assertEquals("wms.hgis.cartomatic.pl", wms.getLayers().get(0).getName());
     
    96102    void testTicket19193() throws IOException, WMSGetCapabilitiesException {
    97103        byte[] capabilities = Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(19193, "capabilities.xml")));
    98         tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(capabilities)));
    99         WMSImagery wms = new WMSImagery(tileServer.url("any"));
     104        tileServer.getWireMock().register(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(capabilities)));
     105        WMSImagery wms = new WMSImagery(tileServer.getHttpBaseUrl() + "/any");
    100106        assertEquals("https://inspire.brandenburg.de/services/gn_alkis_wms?", wms.buildRootUrl());
    101107        assertEquals(1, wms.getLayers().size());
     
    114120    @Test
    115121    void testTicket16333() throws IOException, WMSGetCapabilitiesException {
    116         tileServer.stubFor(
     122        tileServer.getWireMock().register(
    117123                WireMock.get(WireMock.anyUrl())
    118124                .willReturn(WireMock.aResponse().withBody(
     
    120126                ))
    121127        );
    122         WMSImagery wms = new WMSImagery(tileServer.url("any"));
     128        WMSImagery wms = new WMSImagery(tileServer.getHttpBaseUrl() + "/any");
    123129        assertEquals("https://duinoord.xs4all.nl/geoserver/ows?SERVICE=WMS&", wms.buildRootUrl());
    124130        assertNull(wms.getLayers().get(0).getName());
     
    131137    @Test
    132138    void testForTitleWithinAttribution_ticket16940() throws IOException, WMSGetCapabilitiesException {
    133         tileServer.stubFor(
     139        tileServer.getWireMock().register(
    134140                WireMock.get(WireMock.anyUrl())
    135141                .willReturn(WireMock.aResponse().withBody(
     
    137143                ))
    138144        );
    139         WMSImagery wms = new WMSImagery(tileServer.url("any"));
     145        WMSImagery wms = new WMSImagery(tileServer.getHttpBaseUrl() + "/any");
    140146        assertEquals("Hipsográfico", wms.getLayers().stream().findFirst().get().getTitle());
    141147    }
  • trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportSenderTest.java

    r18106 r19155  
    1616import java.util.List;
    1717
     18import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;
    1819import org.junit.jupiter.api.Test;
    1920import org.openstreetmap.josm.actions.ShowStatusReportAction;
     
    2324import org.openstreetmap.josm.testutils.annotations.HTTP;
    2425import org.openstreetmap.josm.testutils.mockers.OpenBrowserMocker;
    25 
    26 import com.github.tomakehurst.wiremock.WireMockServer;
    2726
    2827/**
     
    3433class BugReportSenderTest {
    3534    /**
    36      * HTTP mock
    37      */
    38     @BasicWiremock
    39     WireMockServer wireMockServer;
    40 
    41     /**
    4235     * Unit test for {@link BugReportSender#BugReportSender}.
    4336     * @throws InterruptedException if the thread is interrupted
    4437     */
    4538    @Test
    46     void testBugReportSender() throws InterruptedException {
    47         Config.getPref().put("josm.url", wireMockServer.baseUrl());
    48         wireMockServer.stubFor(post(urlEqualTo("/josmticket"))
     39    void testBugReportSender(WireMockRuntimeInfo wireMockRuntimeInfo) throws InterruptedException {
     40        Config.getPref().put("josm.url", wireMockRuntimeInfo.getHttpBaseUrl());
     41        wireMockRuntimeInfo.getWireMock().register(post(urlEqualTo("/josmticket"))
    4942                .willReturn(aResponse()
    5043                        .withStatus(200)
     
    6659        assertFalse(sender.isAlive());
    6760        assertNull(sender.getErrorMessage(), sender.getErrorMessage());
    68         wireMockServer.verify(exactly(1), postRequestedFor(urlEqualTo("/josmticket")).withRequestBody(containing("pdata=")));
     61        wireMockRuntimeInfo.getWireMock().verifyThat(exactly(1),
     62                postRequestedFor(urlEqualTo("/josmticket")).withRequestBody(containing("pdata=")));
    6963
    7064        List<URI> calledURIs = OpenBrowserMocker.getCalledURIs();
    7165        assertEquals(1, calledURIs.size());
    72         assertEquals(wireMockServer.url("/josmticket?pdata_stored=6bccff5c0417217bfbbe5fff"), calledURIs.get(0).toString());
     66        assertEquals(wireMockRuntimeInfo.getHttpBaseUrl() + "/josmticket?pdata_stored=6bccff5c0417217bfbbe5fff", calledURIs.get(0).toString());
    7367    }
    7468}
Note: See TracChangeset for help on using the changeset viewer.