Making the tests less brittle
This commit is contained in:
@@ -227,8 +227,8 @@ public class WireMockHttpServerStub implements HttpServerStub {
|
||||
String scheme = this.https ? "https" : "http";
|
||||
String host = "localhost";
|
||||
int port = port();
|
||||
String urlPathPrefix = null;
|
||||
String hostHeader = null;
|
||||
String urlPathPrefix = "";
|
||||
String hostHeader = "";
|
||||
String proxyHost = this.wireMockConfiguration.proxyHostHeader();
|
||||
int proxyPort = this.wireMockConfiguration.proxyVia().port();
|
||||
ClientAuthenticator authenticator = NoClientAuthenticator.noClientAuthenticator();
|
||||
|
||||
@@ -19,9 +19,10 @@ package org.springframework.cloud.contract.stubrunner
|
||||
import spock.lang.Specification
|
||||
|
||||
import org.springframework.cloud.contract.stubrunner.provider.wiremock.WireMockHttpServerStub
|
||||
import org.springframework.util.SocketUtils
|
||||
|
||||
class StubServerSpec extends Specification {
|
||||
static final int STUB_SERVER_PORT = 12180
|
||||
static final int STUB_SERVER_PORT = SocketUtils.findAvailableTcpPort()
|
||||
static final URL EXPECTED_URL = new URL("http://localhost:$STUB_SERVER_PORT")
|
||||
|
||||
File repository = new File('src/test/resources/repository/mappings/spring/cloud/bye')
|
||||
@@ -36,6 +37,7 @@ class StubServerSpec extends Specification {
|
||||
pingStubServer.start()
|
||||
then:
|
||||
"http://localhost:$pingStubServer.port/bye".toURL().text == 'Goodbye world!'
|
||||
cleanup:
|
||||
pingStubServer.stop()
|
||||
}
|
||||
|
||||
@@ -48,6 +50,7 @@ class StubServerSpec extends Specification {
|
||||
pingStubServer.start()
|
||||
then:
|
||||
pingStubServer.stubUrl == EXPECTED_URL
|
||||
cleanup:
|
||||
pingStubServer.stop()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user