Ignore:
Timestamp:
2018-05-12T22:08:00+02:00 (3 years ago)
Author:
wiktorn
Message:

Fix tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java

    r13733 r13735  
    77import java.io.IOException;
    88import java.nio.file.Files;
    9 import java.nio.file.Path;
    109import java.nio.file.Paths;
    1110import java.util.List;
     
    1716import org.openstreetmap.josm.testutils.JOSMTestRules;
    1817
    19 import com.github.tomakehurst.wiremock.WireMockServer;
    2018import com.github.tomakehurst.wiremock.client.WireMock;
     19import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
     20import com.github.tomakehurst.wiremock.junit.WireMockRule;
    2121
    2222import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    3434    public JOSMTestRules test = new JOSMTestRules().platform().projection();
    3535
     36    @Rule
     37    public WireMockRule tileServer = new WireMockRule(WireMockConfiguration.options()
     38            .dynamicPort());
    3639    /**
    3740     * Unit test of {@code WMSImagery.WMSGetCapabilitiesException} class
     
    5558    @Test
    5659    public void testTicket15730() throws IOException, WMSGetCapabilitiesException {
    57        WireMockServer wm = TestUtils.getWireMockServer(15730);
    58        wm.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBodyFile("capabilities.xml")));
    59        wm.start();
    60        WMSImagery wms = new WMSImagery(wm.url("capabilities.xml"));
    61        assertEquals(1, wms.getLayers().size());
    62        assertTrue(wms.getLayers().get(0).getAbstract().startsWith("South Carolina  NAIP Imagery 2017    Resolution: 100CM "));
    63        wm.shutdown();
     60        tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(
     61                Files.readAllBytes(Paths.get(TestUtils.getRegressionDataDir(15730), "capabilities.xml"))
     62                )));
     63
     64        WMSImagery wms = new WMSImagery(tileServer.url("capabilities.xml"));
     65        assertEquals(1, wms.getLayers().size());
     66        assertTrue(wms.getLayers().get(0).getAbstract().startsWith("South Carolina  NAIP Imagery 2017    Resolution: 100CM "));
    6467    }
    6568
    6669    @Test
    6770    public void testNestedLayers() throws Exception {
    68         WireMockServer getCapabilitiesMock = TestUtils.getWireMockServer();
    69         String getCapabilitiesBody = new String(Files.readAllBytes(Paths.get(TestUtils.getTestDataRoot() + "wms/mapa-um-warszawa-pl.xml")), "UTF-8");
    70         getCapabilitiesMock.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(getCapabilitiesBody)));
    71         getCapabilitiesMock.start();
    72         WMSImagery wmsi = new WMSImagery(getCapabilitiesMock.url("/serwis"));
     71        tileServer.stubFor(WireMock.get(WireMock.anyUrl()).willReturn(WireMock.aResponse().withBody(
     72                Files.readAllBytes(Paths.get(TestUtils.getTestDataRoot() + "wms/mapa-um-warszawa-pl.xml")))));
     73        WMSImagery wmsi = new WMSImagery(tileServer.url("/serwis"));
    7374        assertEquals(1, wmsi.getLayers().size());
    7475        assertEquals("Server WMS m.st. Warszawy", wmsi.getLayers().get(0).toString());
     
    8384    @Test
    8485    public void testTicket16248() throws IOException, WMSGetCapabilitiesException {
    85         Path capabilitiesPath = Paths.get(TestUtils.getRegressionDataFile(16248, "capabilities.xml"));
    86         WireMockServer getCapabilitiesMock = TestUtils.getWireMockServer();
    87         getCapabilitiesMock.stubFor(
     86        tileServer.stubFor(
    8887                WireMock.get(WireMock.anyUrl())
    89                 .willReturn(WireMock.aResponse().withBody(Files.readAllBytes(capabilitiesPath))));
    90         getCapabilitiesMock.start();
    91         WMSImagery wms = new WMSImagery(getCapabilitiesMock.url("any"));
     88                .willReturn(WireMock.aResponse().withBody(Files.readAllBytes(Paths.get(TestUtils.getRegressionDataFile(16248, "capabilities.xml"))))));
     89        WMSImagery wms = new WMSImagery(tileServer.url("any"));
    9290        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k", wms.buildRootUrl());
    9391        assertEquals("wms.hgis.cartomatic.pl", wms.getLayers().get(0).getName());
Note: See TracChangeset for help on using the changeset viewer.