diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java index e99db2a232..1b691414db 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.restassured; import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -14,7 +15,8 @@ import static io.restassured.RestAssured.get; import static org.hamcrest.Matchers.hasItems; public class RestAssured2IntegrationTest { - private static WireMockServer wireMockServer = new WireMockServer(); + private static final int PORT = 8084; + private static WireMockServer wireMockServer = new WireMockServer(PORT); private static final String EVENTS_PATH = "/odds"; private static final String APPLICATION_JSON = "application/json"; @@ -24,7 +26,8 @@ public class RestAssured2IntegrationTest { public static void before() throws Exception { System.out.println("Setting up!"); wireMockServer.start(); - configureFor("localhost", 8080); + configureFor("localhost", PORT); + RestAssured.port = PORT; stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( aResponse().withStatus(200) .withHeader("Content-Type", APPLICATION_JSON) @@ -38,7 +41,6 @@ public class RestAssured2IntegrationTest { } private static String getJson() { - return Util.inputStreamToString(RestAssured2IntegrationTest.class .getResourceAsStream("/odds.json")); } diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java index 5edf200a40..4ad3cea22c 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java @@ -4,6 +4,7 @@ import com.github.fge.jsonschema.SchemaVersion; import com.github.fge.jsonschema.cfg.ValidationConfiguration; import com.github.fge.jsonschema.main.JsonSchemaFactory; import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -20,8 +21,9 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItems; public class RestAssuredIntegrationTest { + private static final int PORT = 8083; + private static WireMockServer wireMockServer = new WireMockServer(PORT); - private static WireMockServer wireMockServer = new WireMockServer(); private static final String EVENTS_PATH = "/events?id=390"; private static final String APPLICATION_JSON = "application/json"; private static final String GAME_ODDS = getEventJson(); @@ -30,7 +32,8 @@ public class RestAssuredIntegrationTest { public static void before() throws Exception { System.out.println("Setting up!"); wireMockServer.start(); - configureFor("localhost", 8080); + RestAssured.port = PORT; + configureFor("localhost", PORT); stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( aResponse().withStatus(200) .withHeader("Content-Type", APPLICATION_JSON) diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java index 9eef9654a3..4a29d8832f 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.restassured; import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -14,7 +15,8 @@ import static io.restassured.RestAssured.get; import static org.hamcrest.Matchers.hasItems; public class RestAssuredXML2IntegrationTest { - private static WireMockServer wireMockServer = new WireMockServer(); + private static final int PORT = 8082; + private static WireMockServer wireMockServer = new WireMockServer(PORT); private static final String EVENTS_PATH = "/teachers"; private static final String APPLICATION_XML = "application/xml"; @@ -24,7 +26,8 @@ public class RestAssuredXML2IntegrationTest { public static void before() throws Exception { System.out.println("Setting up!"); wireMockServer.start(); - configureFor("localhost", 8080); + RestAssured.port = PORT; + configureFor("localhost", PORT); stubFor(get(urlEqualTo(EVENTS_PATH)).willReturn( aResponse().withStatus(200) .withHeader("Content-Type", APPLICATION_XML) diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java index de2dfa1c89..f1a22831f4 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.restassured; import com.github.tomakehurst.wiremock.WireMockServer; +import io.restassured.RestAssured; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -16,7 +17,9 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.xml.HasXPath.hasXPath; public class RestAssuredXMLIntegrationTest { - private static WireMockServer wireMockServer = new WireMockServer(); + private static final int PORT = 8081; + private static WireMockServer wireMockServer = new WireMockServer(PORT); + private static final String EVENTS_PATH = "/employees"; private static final String APPLICATION_XML = "application/xml"; private static final String EMPLOYEES = getXml(); @@ -25,7 +28,8 @@ public class RestAssuredXMLIntegrationTest { public static void before() throws Exception { System.out.println("Setting up!"); wireMockServer.start(); - configureFor("localhost", 8080); + configureFor("localhost", PORT); + RestAssured.port = PORT; stubFor(post(urlEqualTo(EVENTS_PATH)).willReturn( aResponse().withStatus(200) .withHeader("Content-Type", APPLICATION_XML)