diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BasicTypesTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BasicTypesTest.java index bee7b807a5..147b0eeff3 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BasicTypesTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BasicTypesTest.java @@ -83,7 +83,7 @@ public void helloWorld() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { hello }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -96,7 +96,7 @@ public void integerNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -109,7 +109,7 @@ public void floatingPointNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { floating }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -122,7 +122,7 @@ public void bool() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { bool }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -135,7 +135,7 @@ public void id() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { id }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -148,7 +148,7 @@ public void enumeration() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { enum }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -165,7 +165,7 @@ public void list() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { list }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -182,7 +182,7 @@ public void alias() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { arr: array }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -197,7 +197,7 @@ public void userDefined() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { when }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -210,7 +210,7 @@ public void functionDefault() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { answer }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -223,7 +223,7 @@ public void function() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { answer(name: \"world\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { assertEquals(result, body); testComplete(); })); @@ -236,13 +236,13 @@ public void cached() throws Exception { GraphQLRequest request1 = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { changing }"); - request1.send(client, promise1); + request1.send(client, getServerPort(), promise1); Promise promise2 = Promise.promise(); GraphQLRequest request2 = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { changing }"); - request2.send(client, promise2); + request2.send(client, getServerPort(), promise2); Future.all(promise1.future(), promise2.future()).onComplete(onSuccess(compositeFuture -> { List values = compositeFuture.list(); @@ -260,7 +260,7 @@ public void recursive() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { persons { name , friend { name, friend { name } } } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { JsonObject person = body.getJsonObject("data").getJsonArray("persons").getJsonObject(0); assertEquals("Plato", person.getString("name")); JsonObject friend = person.getJsonObject("friend"); diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BatchRequestsTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BatchRequestsTest.java index 7bded1acca..f0679b20f1 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BatchRequestsTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/BatchRequestsTest.java @@ -37,7 +37,7 @@ protected GraphQLHandlerOptions createOptions() { @Test public void testEmptyBatch() throws Exception { - client.request(HttpMethod.POST, 8080, "localhost", "/graphql") + client.request(HttpMethod.POST, getServerPort(), "localhost", "/graphql") .onComplete(onSuccess(request -> { request.send(new JsonArray().toBuffer()).onComplete(onSuccess(response -> { if (response.statusCode() != 200) { @@ -58,7 +58,7 @@ public void testEmptyBatch() throws Exception { @Test public void testSimpleBatch() throws Exception { - client.request(HttpMethod.POST, 8080, "localhost", "/graphql") + client.request(HttpMethod.POST, getServerPort(), "localhost", "/graphql") .onComplete(onSuccess(request -> { JsonObject query = new JsonObject() .put("query", "query { allLinks { url } }"); @@ -82,7 +82,7 @@ public void testSimpleBatch() throws Exception { @Test public void testMissingQuery() throws Exception { - client.request(HttpMethod.POST, 8080, "localhost", "/graphql") + client.request(HttpMethod.POST, getServerPort(), "localhost", "/graphql") .onComplete(onSuccess(request -> { JsonObject query = new JsonObject() .put("foo", "bar"); diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GetRequestsTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GetRequestsTest.java index 5ea9a23f2f..73e85e97d5 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GetRequestsTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GetRequestsTest.java @@ -35,7 +35,7 @@ public void testSimpleGet() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(GET) .setGraphQLQuery("query { allLinks { url } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { @@ -55,7 +55,7 @@ public void testMultipleQueriesWithOperationName() throws Exception { .setGraphQLQuery(query) .setOperationName("bar") .addVariable("secure", true); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { List expected = testData.urls().stream() .filter(url -> url.startsWith("https://")) .collect(toList()); @@ -74,7 +74,7 @@ public void testSimpleGetWithVariable() throws Exception { .setMethod(GET) .setGraphQLQuery("query($secure: Boolean) { allLinks(secureOnly: $secure) { url } }") .addVariable("secure", true); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { List expected = testData.urls().stream() .filter(url -> url.startsWith("https://")) .collect(toList()); @@ -94,7 +94,7 @@ public void testSimpleGetWithInitialValue() throws Exception { .setGraphQLQuery("query { allLinks { description } }") .setInitialValueAsParam(true) .setInitialValue("100"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { String[] descriptions = new String[testData.links.size()]; Arrays.fill(descriptions,"100"); List expected = Arrays.asList(descriptions); @@ -112,7 +112,7 @@ public void testSimpleGetNoInitialValue() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(GET) .setGraphQLQuery("query { allLinks { description } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkDescriptions(testData.descriptions(), body)) { testComplete(); } else { @@ -126,7 +126,7 @@ public void testSimpleGetNoInitialValue() throws Exception { public void testGetNoQuery() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(GET); - request.send(client, 400, onSuccess(v -> { + request.send(client, 400, getServerPort(), onSuccess(v -> { testComplete(); })); await(); @@ -137,7 +137,7 @@ public void testGetInvalidVariable() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(GET) .setHttpQueryString("query=" + encode("query { allLinks { url } }") + "&variables=" + encode("[1,2,3]")); - request.send(client, 400, onSuccess(v -> { + request.send(client, 400, getServerPort(), onSuccess(v -> { testComplete(); })); await(); diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GraphQLRequest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GraphQLRequest.java index 0a6673b584..e5e8d3f747 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GraphQLRequest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/GraphQLRequest.java @@ -129,14 +129,14 @@ GraphQLRequest setInitialValue(Object initialValue) { return this; } - void send(HttpClient client, Handler> handler) throws Exception { - send(client, 200, handler); + void send(HttpClient client, int serverPort, Handler> handler) throws Exception { + send(client, 200, serverPort, handler); } - void send(HttpClient client, int expectedStatus, Handler> handler) throws Exception { + void send(HttpClient client, int expectedStatus, int serverPort, Handler> handler) throws Exception { Promise promise = Promise.promise(); promise.future().onComplete(handler); - Future fut = client.request(method, 8080, "localhost", getUri()); + Future fut = client.request(method, serverPort, "localhost", getUri()); fut.onComplete(ar1 -> { if (ar1.succeeded()) { HttpClientRequest request = ar1.result(); diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/JsonResultsTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/JsonResultsTest.java index 90bfb50763..c2d1cf4ba5 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/JsonResultsTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/JsonResultsTest.java @@ -77,7 +77,7 @@ public void testSimpleGet() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(GET) .setGraphQLQuery("query { allLinks { url } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { @@ -91,7 +91,7 @@ public void testSimpleGet() throws Exception { public void testSimplePost() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { url } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/LocaleTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/LocaleTest.java index 1ce9367b81..51b02a76ff 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/LocaleTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/LocaleTest.java @@ -89,7 +89,7 @@ public void testLocale() throws Exception { .setMethod(GET) .setLocale(LOCALE) .setGraphQLQuery("query { locale }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (body.getJsonObject("data").getString("locale").equals(LOCALE)) { testComplete(); } else { @@ -105,7 +105,7 @@ public void testEmptyLocaleDefaulsToSystemLocale() throws Exception { .setMethod(GET) .setLocale("") .setGraphQLQuery("query { locale }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { Locale expectedLocale = Locale.getDefault(); String actualLocale = body.getJsonObject("data").getString("locale"); @@ -123,7 +123,7 @@ public void testMultipleLocale() throws Exception { .setMethod(GET) .setLocale(LOCALE + ",en-GB") .setGraphQLQuery("query { locale }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (body.getJsonObject("data").getString("locale").equals(LOCALE)) { testComplete(); } else { @@ -139,7 +139,7 @@ public void testMultipleWrongLocales() throws Exception { .setMethod(GET) .setLocale(",,,," + LOCALE) .setGraphQLQuery("query { locale }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (body.getJsonObject("data").getString("locale").equals(LOCALE)) { testComplete(); } else { diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/MultipartRequestTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/MultipartRequestTest.java index 0f1d697fb6..fb07c1fabe 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/MultipartRequestTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/MultipartRequestTest.java @@ -83,7 +83,7 @@ private GraphQL graphQL() { @Test public void testSingleUploadMutation() { - final HttpClient client = vertx.createHttpClient(getHttpClientOptions()); + final HttpClient client = vertx.createHttpClient(getHttpClientOptions(getServerPort())); final Buffer bodyBuffer = vertx.fileSystem().readFileBlocking("singleUpload.txt"); @@ -106,7 +106,7 @@ public void testSingleUploadMutation() { @Test public void testMultipleUploadMutation() { - final HttpClient client = vertx.createHttpClient(getHttpClientOptions()); + final HttpClient client = vertx.createHttpClient(getHttpClientOptions(getServerPort())); final Buffer bodyBuffer = vertx.fileSystem().readFileBlocking("multipleUpload.txt"); client.request(new RequestOptions() @@ -127,7 +127,7 @@ public void testMultipleUploadMutation() { @Test public void testBatchUploadMutation() { - final HttpClient client = vertx.createHttpClient(getHttpClientOptions()); + final HttpClient client = vertx.createHttpClient(getHttpClientOptions(getServerPort())); final Buffer bodyBuffer = vertx.fileSystem().readFileBlocking("batchUpload.txt"); client.request(new RequestOptions() diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/PostRequestsTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/PostRequestsTest.java index 3634c28dfc..3dc97207f5 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/PostRequestsTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/PostRequestsTest.java @@ -38,7 +38,7 @@ public class PostRequestsTest extends GraphQLTestBase { public void testSimplePost() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { url } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { @@ -53,7 +53,7 @@ public void testSimplePostNoContentType() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { url } }") .setContentType(null); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { @@ -68,7 +68,7 @@ public void testSimplePostQueryInParam() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { url } }") .setGraphQLQueryAsParam(true); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { @@ -83,7 +83,7 @@ public void testSimplePostQueryAsBody() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { url } }") .setContentType(GRAPHQL); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { @@ -102,7 +102,7 @@ public void testMultipleQueriesWithOperationName() throws Exception { .setGraphQLQuery(query) .setOperationName("bar") .addVariable("secure", true); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { List expected = testData.urls().stream() .filter(url -> url.startsWith("https://")) .collect(toList()); @@ -120,7 +120,7 @@ public void testSimplePostWithVariable() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query($secure: Boolean) { allLinks(secureOnly: $secure) { url } }") .addVariable("secure", true); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { List expected = testData.urls().stream() .filter(url -> url.startsWith("https://")) .collect(toList()); @@ -139,7 +139,7 @@ public void testSimplePostWithInitialValueInParam() throws Exception { .setGraphQLQuery("query { allLinks { description } }") .setInitialValue(12345) .setInitialValueAsParam(true); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { String[] values = new String[testData.links.size()]; Arrays.fill(values, "12345"); List expected = Arrays.asList(values); @@ -157,7 +157,7 @@ public void testSimplePostWithInitialValue() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { description } }") .setInitialValue(12345); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { String[] values = new String[testData.links.size()]; Arrays.fill(values, "12345"); List expected = Arrays.asList(values); @@ -174,7 +174,7 @@ public void testSimplePostWithInitialValue() throws Exception { public void testSimplePostWithNoInitialValue() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { description } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkDescriptions(testData.descriptions(), body)) { testComplete(); } else { @@ -188,7 +188,7 @@ public void testSimplePostWithNoInitialValue() throws Exception { public void testPostNoQuery() throws Exception { GraphQLRequest request = new GraphQLRequest() .setRequestBody(new JsonObject().put("foo", "bar").toBuffer()); - request.send(client, 400, onSuccess(v -> { + request.send(client, 400, getServerPort(), onSuccess(v -> { testComplete(); })); await(); @@ -198,7 +198,7 @@ public void testPostNoQuery() throws Exception { public void testPostInvalidJson() throws Exception { GraphQLRequest request = new GraphQLRequest() .setRequestBody(new JsonArray().add("foo").add("bar").toBuffer()); - request.send(client, 400, onSuccess(v -> { + request.send(client, 400, getServerPort(), onSuccess(v -> { testComplete(); })); await(); @@ -209,7 +209,7 @@ public void testPostWithInvalidVariableParam() throws Exception { GraphQLRequest request = new GraphQLRequest() .setHttpQueryString("query=" + encode("query { allLinks { url } }") + "&variables=" + encode("[1,2,3]")) .setRequestBody(null); - request.send(client, 400, onSuccess(body -> { + request.send(client, 400, getServerPort(), onSuccess(body -> { testComplete(); })); await(); @@ -233,7 +233,7 @@ public void testContentTypeWithCharset() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { url } }") .setContentType("application/json; charset=UTF-8"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/UnsupportedMethodTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/UnsupportedMethodTest.java index 377542ca01..9461865cd2 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/UnsupportedMethodTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/UnsupportedMethodTest.java @@ -30,7 +30,7 @@ public void testUnsupportedMethod() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(PUT) .setGraphQLQuery("query { allLinks { url } }"); - request.send(client, 405, onSuccess(v -> { + request.send(client, 405, getServerPort(), onSuccess(v -> { testComplete(); })); await(); diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/ValidationTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/ValidationTest.java index 99a34fc870..64f002b8ec 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/ValidationTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/ValidationTest.java @@ -178,7 +178,7 @@ public void validString() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { text(type: \"valid\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -193,7 +193,7 @@ public void nullString() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { text(type: \"null\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasError()); assertFalse(result.hasData()); @@ -207,7 +207,7 @@ public void eolString() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { text(type: \"eol\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -224,7 +224,7 @@ public void emptyString() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { text(type: \"empty\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasError()); assertTrue(result.hasData()); @@ -239,7 +239,7 @@ public void jsonString() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { text(type: \"brokenjson\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -254,7 +254,7 @@ public void i18nString() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { text(type: \"non-ascii\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -269,7 +269,7 @@ public void longString() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { text(type: \"long\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -284,7 +284,7 @@ public void number() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"positive\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -299,7 +299,7 @@ public void negativeNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"negative\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -314,7 +314,7 @@ public void maxNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"max\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -329,7 +329,7 @@ public void minNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"min\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -344,7 +344,7 @@ public void zero() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"zero\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -359,7 +359,7 @@ public void tooBigNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"huge\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -373,7 +373,7 @@ public void tooSmallNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"tiny\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -387,7 +387,7 @@ public void wayTooBigNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"overwhelming\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -401,7 +401,7 @@ public void nullNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"null\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -415,7 +415,7 @@ public void notInteger() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"float\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -429,7 +429,7 @@ public void notNumber() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { number(type: \"string\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -443,7 +443,7 @@ public void floating() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { floating(type: \"valid\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -458,7 +458,7 @@ public void nullFloat() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { floating(type: \"null\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -472,7 +472,7 @@ public void boolTrue() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { bool(type: \"yes\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -487,7 +487,7 @@ public void boolFalse() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { bool(type: \"no\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -502,7 +502,7 @@ public void boolNull() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { bool(type: \"null\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertFalse(result.hasData()); assertTrue(result.hasError()); @@ -516,7 +516,7 @@ public void listValid() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { list(type: \"valid\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); JsonArray list = result.data().getJsonArray("list"); @@ -531,7 +531,7 @@ public void arrayValid() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { array(type: \"valid\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); JsonArray list = result.data().getJsonArray("array"); @@ -546,7 +546,7 @@ public void listJava() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { list(type: \"object\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); JsonArray list = result.data().getJsonArray("list"); @@ -561,7 +561,7 @@ public void arrayJava() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { array(type: \"object\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); JsonArray list = result.data().getJsonArray("array"); @@ -576,7 +576,7 @@ public void listEmpty() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { list(type: \"empty\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); JsonArray list = result.data().getJsonArray("list"); @@ -591,7 +591,7 @@ public void arrayEmpty() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { array(type: \"empty\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); JsonArray list = result.data().getJsonArray("array"); @@ -606,7 +606,7 @@ public void listNull() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { list(type: \"null\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasError()); assertFalse(result.hasData()); @@ -620,7 +620,7 @@ public void arrayNull() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { array(type: \"null\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -635,7 +635,7 @@ public void listWithNulls() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { list(type: \"nullvalues\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasData()); assertFalse(result.hasError()); @@ -654,7 +654,7 @@ public void arrayWithNulls() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { array(type: \"nullvalues\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasError()); testComplete(); @@ -667,7 +667,7 @@ public void listScalar() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { list(type: \"scalar\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasError()); assertFalse(result.hasData()); @@ -681,7 +681,7 @@ public void arrayScalar() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(POST) .setGraphQLQuery("query { array(type: \"scalar\") }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { ValidationResult result = new ValidationResult(body); assertTrue(result.hasError()); assertNull(result.data().getValue("array")); diff --git a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/VertxFutureInstrumentationTest.java b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/VertxFutureInstrumentationTest.java index e61ec7913d..539e405602 100644 --- a/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/VertxFutureInstrumentationTest.java +++ b/vertx-web-graphql/src/test/java/io/vertx/ext/web/handler/graphql/VertxFutureInstrumentationTest.java @@ -59,7 +59,7 @@ public void testSimpleGet() throws Exception { GraphQLRequest request = new GraphQLRequest() .setMethod(GET) .setGraphQLQuery("query { allLinks { url } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { @@ -73,7 +73,7 @@ public void testSimpleGet() throws Exception { public void testSimplePost() throws Exception { GraphQLRequest request = new GraphQLRequest() .setGraphQLQuery("query { allLinks { url } }"); - request.send(client, onSuccess(body -> { + request.send(client, getServerPort(), onSuccess(body -> { if (testData.checkLinkUrls(testData.urls(), body)) { testComplete(); } else { diff --git a/vertx-web/pom.xml b/vertx-web/pom.xml index 263fb04b97..9a44a52a51 100644 --- a/vertx-web/pom.xml +++ b/vertx-web/pom.xml @@ -81,6 +81,11 @@ vertx-health-check true + + io.vertx + vertx-config + true + diff --git a/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java b/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java index c3530e7df6..c6471eaef0 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/ForwardedTest.java @@ -336,7 +336,7 @@ public void testXForwardedPortAndHostWithPort() throws Exception { @Test public void testIllegalPort() throws Exception { router.allowForward(ALL).route("/").handler(rc -> { - assertTrue(rc.request().authority().toString().endsWith(":8080")); + assertTrue(rc.request().authority().toString().endsWith(":"+ getServerPort())); rc.end(); }); @@ -453,7 +453,7 @@ private void testMissingHostHeader(Route route) throws Exception { public void testNoForwarded() throws Exception { router.allowForward(ALL).route("/").handler(rc -> { assertTrue(rc.request().remoteAddress().host().equals("127.0.0.1")); - assertTrue(rc.request().authority().toString().equals("localhost:8080")); + assertTrue(rc.request().authority().toString().equals("localhost:"+ getServerPort())); assertTrue(rc.request().scheme().equals("http")); assertFalse(rc.request().isSSL()); rc.end(); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java b/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java index 752e5a224e..e4768e80d0 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/RouterTest.java @@ -2794,7 +2794,7 @@ public void testVHost() throws Exception { router.route().handler(ctx -> ctx.fail(500)); testRequest(new RequestOptions() - .setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + .setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setPort(80) .setHost("www.mysite.com"), req -> { }, 200, "OK", null); @@ -2807,7 +2807,7 @@ public void testVHostShouldFail() throws Exception { router.route().handler(ctx -> ctx.fail(500)); testRequest(new RequestOptions() - .setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + .setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setPort(80) .setHost("www.mysite.net"), req -> { }, 500, "Internal Server Error", null); @@ -3228,7 +3228,7 @@ public void testPauseResumeOnPipeline() { }); Function, String> test = reqs -> { - try (Socket socket = new Socket("localhost", 8080)) { + try (Socket socket = new Socket("localhost", getServerPort())) { OutputStream output = socket.getOutputStream(); PrintWriter writer = new PrintWriter(output, true); @@ -3490,7 +3490,7 @@ public void testPausedConnection() { HttpClient client = vertx.createHttpClient(new PoolOptions().setHttp1MaxSize(1)); for (int i = 0;i < numRequests;i++) { - client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(8080)).onComplete(onSuccess(req -> { + client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(getServerPort())).onComplete(onSuccess(req -> { // 8192 * 8 fills the HTTP server request pending queue // => pauses the HttpConnection (see Http1xServerRequest#handleContent(Buffer) that calls Http1xServerConnection#doPause()) req.send(TestUtils.randomBuffer(8192 * 8)).onComplete(onSuccess(resp -> { @@ -3525,7 +3525,7 @@ public void testPausedConnection2() { HttpClient client = vertx.createHttpClient(new PoolOptions().setHttp1MaxSize(1)); for (int i = 0;i < numRequests;i++) { - client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(8080)).onComplete(onSuccess(req -> { + client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(getServerPort())).onComplete(onSuccess(req -> { // 8192 * 8 fills the HTTP server request pending queue // => pauses the HttpConnection (see Http1xServerRequest#handleContent(Buffer) that calls Http1xServerConnection#doPause()) req.send(TestUtils.randomBuffer(8192 * 8)).onComplete(onSuccess(resp -> { @@ -3563,7 +3563,7 @@ public void testPausedConnection3() { HttpClient client = vertx.createHttpClient(new PoolOptions().setHttp1MaxSize(1)); for (int i = 0;i < numRequests;i++) { - client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(8080)).onComplete(onSuccess(req -> { + client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(getServerPort())).onComplete(onSuccess(req -> { // 8192 * 8 fills the HTTP server request pending queue // => pauses the HttpConnection (see Http1xServerRequest#handleContent(Buffer) that calls Http1xServerConnection#doPause()) req.send(TestUtils.randomBuffer(8192 * 8)).onComplete(onSuccess(resp -> { @@ -3591,7 +3591,7 @@ public void testPausedConnection4() { HttpClient client = vertx.createHttpClient(new PoolOptions().setHttp1MaxSize(1)); for (int i = 0;i < numRequests;i++) { - client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(8080)).onComplete(onSuccess(req -> { + client.request(new RequestOptions().setMethod(HttpMethod.PUT).setPort(getServerPort())).onComplete(onSuccess(req -> { // 8192 * 8 fills the HTTP server request pending queue // => pauses the HttpConnection (see Http1xServerRequest#handleContent(Buffer) that calls Http1xServerConnection#doPause()) req.send(TestUtils.randomBuffer(8192 * 8)).onComplete(onSuccess(resp -> { diff --git a/vertx-web/src/test/java/io/vertx/ext/web/VirtualHostTest.java b/vertx-web/src/test/java/io/vertx/ext/web/VirtualHostTest.java index e695329861..8a8e7bf04d 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/VirtualHostTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/VirtualHostTest.java @@ -30,7 +30,7 @@ public void testVHost() throws Exception { router.route().handler(ctx -> ctx.fail(500)); - testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setHost("www.mysite.com") .setPort(80), req -> {}, 200, "OK", null); } @@ -41,8 +41,8 @@ public void testVHostPort() throws Exception { router.route().handler(ctx -> ctx.fail(500)); - testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(8080, "localhost")) - .setHost("www.mysite.com:8080") + testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) + .setHost("www.mysite.com:"+ getServerPort()) .setPort(80), req -> {}, 200, "OK", null); } @@ -52,7 +52,7 @@ public void testVHostIPv6Any() throws Exception { router.route().handler(ctx -> ctx.fail(500)); - testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setHost("[::]") .setPort(80), req -> {}, 200, "OK", null); } @@ -63,8 +63,8 @@ public void testVHostIPv6AnyPort() throws Exception { router.route().handler(ctx -> ctx.fail(500)); - testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(8080, "localhost")) - .setHost("[::]:8080") + testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) + .setHost("[::]:"+ getServerPort()) .setPort(80), req -> {}, 200, "OK", null); } @@ -74,7 +74,7 @@ public void testVHostIPv6Home() throws Exception { router.route().handler(ctx -> ctx.fail(500)); - testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setHost("[::1]") .setPort(80), req -> {}, 200, "OK", null); } @@ -85,8 +85,8 @@ public void testVHostIPv6HomePort() throws Exception { router.route().handler(ctx -> ctx.fail(500)); - testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(8080, "localhost")) - .setHost("[::1]:8080") + testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) + .setHost("[::1]:"+ getServerPort()) .setPort(80), req -> {}, 200, "OK", null); } @@ -96,7 +96,7 @@ public void testVHostShouldFail() throws Exception { router.route().handler(ctx -> ctx.fail(500)); - testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + testRequest(new RequestOptions().setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setHost("www.mysite.net") .setPort(80), req -> {}, 500, "Internal Server Error", null); } @@ -109,7 +109,7 @@ public void testVHostSubRouter() throws Exception { router.route("/*").virtualHost("*.com").subRouter(a); testRequest(new RequestOptions() - .setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + .setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setHost("www.mysite.com") .setPort(80) .setURI("/somepath"), req -> {}, 200, "OK", null); @@ -118,7 +118,7 @@ public void testVHostSubRouter() throws Exception { router.route().virtualHost("*.com").subRouter(a); testRequest(new RequestOptions() - .setServer(SocketAddress.inetSocketAddress(8080, "localhost")) + .setServer(SocketAddress.inetSocketAddress(getServerPort(), "localhost")) .setHost("www.mysite.com") .setPort(80) .setURI("/somepath"), req -> {}, 200, "OK", null); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/WebTestBase.java b/vertx-web/src/test/java/io/vertx/ext/web/WebTestBase.java index 9c5d521f63..2e61c11c7c 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/WebTestBase.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/WebTestBase.java @@ -17,6 +17,10 @@ package io.vertx.ext.web; import io.netty.handler.codec.http.HttpResponseStatus; +import io.vertx.config.ConfigRetriever; +import io.vertx.config.ConfigRetrieverOptions; +import io.vertx.config.ConfigStoreOptions; +import io.vertx.core.Future; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.*; import io.vertx.ext.web.handler.BodyHandler; @@ -49,29 +53,48 @@ public class WebTestBase extends VertxTestBase { protected HttpClient client; protected WebSocketClient wsClient; protected Router router; + protected static Integer serverPort; @Override public void setUp() throws Exception { super.setUp(); - router = Router.router(vertx); - server = vertx.createHttpServer(getHttpServerOptions()); - client = vertx.createHttpClient(getHttpClientOptions()); - wsClient = vertx.createWebSocketClient(getWebSocketClientOptions()); + + ConfigStoreOptions sysStore = new ConfigStoreOptions() + .setType("sys"); + + ConfigRetriever retriever = ConfigRetriever.create(vertx, + new ConfigRetrieverOptions() + .addStore(sysStore) + ); + CountDownLatch latch = new CountDownLatch(1); - server.requestHandler(router).listen().onComplete(onSuccess(res -> latch.countDown())); + retriever.getConfig().map(config -> config.getInteger("port", 0)).flatMap(port -> { + router = Router.router(vertx); + server = vertx.createHttpServer(getHttpServerOptions(port)); + return Future.succeededFuture(port); + }).onComplete(__ -> server.requestHandler(router).listen().onComplete(onSuccess(res -> { + serverPort = res.actualPort(); + client = vertx.createHttpClient(getHttpClientOptions(serverPort)); + wsClient = vertx.createWebSocketClient(getWebSocketClientOptions(serverPort)); + latch.countDown(); + }))); awaitLatch(latch); } - protected HttpServerOptions getHttpServerOptions() { - return new HttpServerOptions().setPort(8080).setHost("localhost"); + protected static Integer getServerPort() { + return serverPort; + } + + protected HttpServerOptions getHttpServerOptions(int port) { + return new HttpServerOptions().setPort(port).setHost("localhost"); } - protected HttpClientOptions getHttpClientOptions() { - return new HttpClientOptions().setDefaultPort(8080); + protected HttpClientOptions getHttpClientOptions(int port) { + return new HttpClientOptions().setDefaultPort(port); } - protected WebSocketClientOptions getWebSocketClientOptions() { - return new WebSocketClientOptions().setDefaultPort(8080); + protected WebSocketClientOptions getWebSocketClientOptions(int port) { + return new WebSocketClientOptions().setDefaultPort(port); } @Override @@ -197,7 +220,7 @@ protected void testRequestBuffer(RequestOptions requestOptions, Consumer requestAction, Consumer responseAction, int statusCode, String statusMessage, Buffer responseBodyBuffer, boolean normalizeLineEndings) throws Exception { - testRequestBuffer(client, method, 8080, path, requestAction, responseAction, statusCode, statusMessage, responseBodyBuffer, normalizeLineEndings); + testRequestBuffer(client, method, serverPort, path, requestAction, responseAction, statusCode, statusMessage, responseBodyBuffer, normalizeLineEndings); } protected void testRequestBuffer(HttpClient client, RequestOptions requestOptions, Consumer requestAction, Consumer responseAction, diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/BodyHandlerTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/BodyHandlerTest.java index baf5fe14ac..a9d920aff5 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/handler/BodyHandlerTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/BodyHandlerTest.java @@ -458,7 +458,7 @@ public void testRoutingContextFailedBeforeFileIsFullyUploaded() throws Exception RequestOptions requestOptions = new RequestOptions() .setMethod(HttpMethod.POST) .setHost("localhost") - .setPort(8080) + .setPort(getServerPort()) .setURI("/upload"); client.request(requestOptions).onComplete(onSuccess(req -> { req.response().onComplete(onSuccess(resp -> { diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/CSRFHandlerTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/CSRFHandlerTest.java index 6b09ebdb82..79dab2e34c 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/handler/CSRFHandlerTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/CSRFHandlerTest.java @@ -553,7 +553,7 @@ public void testPostWithNoResponse() throws Exception { // this request will never return but may incorrectly consume a valid token client.request( new RequestOptions().setMethod(HttpMethod.POST) - .setHost("localhost").setPort(8080).setURI("/broken") + .setHost("localhost").setPort(getServerPort()).setURI("/broken") .putHeader(CSRFHandler.DEFAULT_HEADER_NAME, tmpCookie) .putHeader("Cookie", cookieJar.get()) ).onComplete(onSuccess(req -> { @@ -617,7 +617,7 @@ public void simultaneousGetAndPostDoesNotOverrideTokenInSession() throws Excepti client.request( new RequestOptions().setMethod(HttpMethod.GET) .putHeader("Cookie", cookieJar.get()) - .setHost("localhost").setPort(8080).setURI("/csrf/first") + .setHost("localhost").setPort(getServerPort()).setURI("/csrf/first") ).compose(HttpClientRequest::send).onComplete(onSuccess(res -> { assertThat("Should not send set-cookie header", res.headers().get("set-cookie"), nullValue()); latch.countDown(); @@ -627,7 +627,7 @@ public void simultaneousGetAndPostDoesNotOverrideTokenInSession() throws Excepti new RequestOptions().setMethod(HttpMethod.POST) .putHeader("Cookie", cookieJar.get()) .putHeader(CSRFHandler.DEFAULT_HEADER_NAME, tmpCookie) - .setHost("localhost").setPort(8080).setURI("/csrf/second") + .setHost("localhost").setPort(getServerPort()).setURI("/csrf/second") ).compose(HttpClientRequest::send).onComplete(onSuccess(res -> { assertEquals("Should only have one set-cookie", 1, res.headers().getAll("set-cookie").size()); final String cookie = res.headers().get("set-cookie"); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2AuthHandlerTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2AuthHandlerTest.java index 8280bdb8c9..534be47c46 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2AuthHandlerTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2AuthHandlerTest.java @@ -94,7 +94,7 @@ public void testAuthCodeFlow() throws Exception { latch.await(); // create a oauth2 handler on our domain to the callback: "http://localhost:8080/callback" - OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:8080/callback"); + OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback"); // setup the callback handler for receiving the callback oauth2Handler.setupCallback(router.route("/callback")); @@ -154,7 +154,7 @@ public void testAuthCodeFlowWithScopes() throws Exception { // create a oauth2 handler on our domain to the callback: "http://localhost:8080/callback" OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler - .create(vertx, oauth2, "http://localhost:8080/callback") + .create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback") // require "read" scope .withScope("read"); @@ -216,7 +216,7 @@ public void testAuthCodeFlowWithScopesInvalid() throws Exception { // create a oauth2 handler on our domain to the callback: "http://localhost:8080/callback" OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler - .create(vertx, oauth2, "http://localhost:8080/callback") + .create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback") // require "rea" scope (will fail) .withScope("rea"); @@ -277,7 +277,7 @@ public void testAuthCodeFlowWithScopesFromMetadata() throws Exception { // create a oauth2 handler on our domain to the callback: "http://localhost:8080/callback" OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler - .create(vertx, oauth2, "http://localhost:8080/callback"); + .create(vertx, oauth2, "http://localhost:"+ getServerPort()+"/callback"); // setup the callback handler for receiving the callback oauth2Handler.setupCallback(router.route("/callback")); @@ -339,7 +339,7 @@ public void testAuthCodeFlowWithScopesFromMetadataNoMatch() throws Exception { // create a oauth2 handler on our domain to the callback: "http://localhost:8080/callback" OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler - .create(vertx, oauth2, "http://localhost:8080/callback"); + .create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback"); // setup the callback handler for receiving the callback oauth2Handler.setupCallback(router.route("/callback")); @@ -406,7 +406,7 @@ public void testAuthCodeFlowBypass() throws Exception { latch.await(); // create a oauth2 handler on our domain to the callback: "http://localhost:8080/callback" - OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:8080/callback"); + OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback"); // setup the callback handler for receiving the callback oauth2Handler.setupCallback(router.route("/callback")); @@ -489,7 +489,7 @@ public void testAuthPKCECodeFlow() throws Exception { // create a oauth2 handler on our domain to the callback: "http://localhost:8080/callback" OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler - .create(vertx, oauth2, "http://localhost:8080/callback") + .create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback") .pkceVerifierLength(64); // setup the callback handler for receiving the callback oauth2Handler.setupCallback(router.route("/callback")); @@ -579,7 +579,7 @@ public void testAuthCodeFlowBadSetup() throws Exception { router.route() .handler( OAuth2AuthHandler - .create(vertx, oauth2, "http://localhost:8080/callback") + .create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback") .setupCallback(router.route("/callback"))); // mount some handler under the protected zone @@ -604,7 +604,7 @@ public void testAuthCodeFlowBadSetup() throws Exception { // protect everything. OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler - .create(vertx, oauth2, "http://localhost:8080/callback") + .create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback") .setupCallback(router.route("/callback")); // now the callback is registered before as it should @@ -854,7 +854,7 @@ public void testAuthCodeFlowSubRouter() throws Exception { router.route("/secret*").subRouter(subRouter); // create a oauth2 handler on our domain to the callback: "http://localhost:8080/secret/callback" - OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:8080/secret/callback"); + OAuth2AuthHandler oauth2Handler = OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:"+getServerPort()+"/secret/callback"); // setup the callback handler for receiving the callback oauth2Handler.setupCallback(subRouter.route("/callback")); @@ -886,7 +886,7 @@ public void testSharing() throws Exception { OAuth2AuthHandler oauth2 = OAuth2AuthHandler.create(vertx, OAuth2Auth.create(vertx, new OAuth2Options() .setClientId("client-id") .setClientSecret("client-secret") - .setSite("http://localhost:10000")), "http://localhost:8080/secret/callback"); + .setSite("http://localhost:10000")), "http://localhost:"+getServerPort()+"/secret/callback"); router.route("/protected/*").handler(oauth2.setupCallback(router.route("/callback"))); router.route("/protected/userinfo").handler(oauth2); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2ImpersonationTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2ImpersonationTest.java index 61a10585ec..2cfa95a25f 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2ImpersonationTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/OAuth2ImpersonationTest.java @@ -160,7 +160,7 @@ public void testSwitchUser() throws Exception { // create an oauth2 handler on our domain to the callback: "http://localhost:8080/callback" and // protect everything under /protected router.route("/protected/*") - .handler(OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:8080/callback").setupCallback(router.route("/callback"))); + .handler(OAuth2AuthHandler.create(vertx, oauth2, "http://localhost:"+getServerPort()+"/callback").setupCallback(router.route("/callback"))); final AtomicReference userRef = new AtomicReference<>(); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/RerouteTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/RerouteTest.java index 574a5f3860..89befb633d 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/handler/RerouteTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/RerouteTest.java @@ -139,7 +139,7 @@ public void testRerouteWithParams() throws Exception { @Test public void testRerouteAbsoluteURI() throws Exception { router.get("/other").handler(ctx -> { - assertEquals("http://localhost:8080/other?paramter1=p1¶meter2=p2", ctx.request().absoluteURI()); + assertEquals("http://localhost:"+getServerPort()+"/other?paramter1=p1¶meter2=p2", ctx.request().absoluteURI()); // assert the parameters have been parsed assertEquals("p1", ctx.queryParam("paramter1").get(0)); assertEquals("p2", ctx.queryParam("parameter2").get(0)); @@ -163,7 +163,7 @@ public void testRerouteChecksWithQuery() throws Exception { assertEquals("/other", req.path()); assertEquals("paramter1=p1¶meter2=p2", req.query()); assertEquals("/other?paramter1=p1¶meter2=p2", req.uri()); - assertEquals("http://localhost:8080/other?paramter1=p1¶meter2=p2", req.absoluteURI()); + assertEquals("http://localhost:"+getServerPort()+"/other?paramter1=p1¶meter2=p2", req.absoluteURI()); // assert the parameters have been parsed assertEquals("p1", ctx.queryParam("paramter1").get(0)); @@ -177,7 +177,7 @@ public void testRerouteChecksWithQuery() throws Exception { assertEquals("/base", req.path()); assertEquals("p=1", req.query()); assertEquals("/base?p=1", req.uri()); - assertEquals("http://localhost:8080/base?p=1", req.absoluteURI()); + assertEquals("http://localhost:"+getServerPort()+"/base?p=1", req.absoluteURI()); ctx.reroute("/other?paramter1=p1¶meter2=p2"); }); @@ -195,7 +195,7 @@ public void testRerouteChecksWithQueryAndFragment() throws Exception { assertEquals("/other", req.path()); assertEquals("paramter1=p1¶meter2=p2", req.query()); assertEquals("/other?paramter1=p1¶meter2=p2#frag", req.uri()); - assertEquals("http://localhost:8080/other?paramter1=p1¶meter2=p2#frag", req.absoluteURI()); + assertEquals("http://localhost:"+getServerPort()+"/other?paramter1=p1¶meter2=p2#frag", req.absoluteURI()); // assert the parameters have been parsed assertEquals("p1", ctx.queryParam("paramter1").get(0)); @@ -209,7 +209,7 @@ public void testRerouteChecksWithQueryAndFragment() throws Exception { assertEquals("/base", req.path()); assertEquals("p=1", req.query()); assertEquals("/base?p=1", req.uri()); - assertEquals("http://localhost:8080/base?p=1", req.absoluteURI()); + assertEquals("http://localhost:"+getServerPort()+"/base?p=1", req.absoluteURI()); ctx.reroute("/other?paramter1=p1¶meter2=p2#frag"); }); @@ -227,7 +227,7 @@ public void testRerouteChecksWithFragment() throws Exception { assertEquals("/other", req.path()); assertNull(req.query()); assertEquals("/other#frag", req.uri()); - assertEquals("http://localhost:8080/other#frag", req.absoluteURI()); + assertEquals("http://localhost:"+getServerPort()+"/other#frag", req.absoluteURI()); ctx.response().end("/other"); }); router.get("/base").handler(ctx -> { @@ -237,7 +237,7 @@ public void testRerouteChecksWithFragment() throws Exception { assertEquals("/base", req.path()); assertEquals("p=1", req.query()); assertEquals("/base?p=1", req.uri()); - assertEquals("http://localhost:8080/base?p=1", req.absoluteURI()); + assertEquals("http://localhost:"+getServerPort()+"/base?p=1", req.absoluteURI()); ctx.reroute("/other#frag"); }); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/StaticHandlerTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/StaticHandlerTest.java index 477b3e64a6..8522c33daa 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/handler/StaticHandlerTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/StaticHandlerTest.java @@ -309,11 +309,11 @@ public void testSkipCompressionForSuffixes() throws Exception { private void testSkipCompression(StaticHandler staticHandler, List uris, List expectedContentEncodings) throws Exception { server.close(); - server = vertx.createHttpServer(getHttpServerOptions().setPort(0).setCompressionSupported(true)); + server = vertx.createHttpServer(getHttpServerOptions(getServerPort()).setPort(0).setCompressionSupported(true)); router = Router.router(vertx); router.route().handler(staticHandler); awaitFuture(server.requestHandler(router).listen()); - CompositeFuture cf = uris.stream().map(uri -> client.request(HttpMethod.GET, server.actualPort(), getHttpClientOptions().getDefaultHost(), uri) + CompositeFuture cf = uris.stream().map(uri -> client.request(HttpMethod.GET, server.actualPort(), getHttpClientOptions(getServerPort()).getDefaultHost(), uri) .compose(req -> { return req .putHeader(ACCEPT_ENCODING, String.join(", ", "gzip", "jpg", "jpeg", "png")) @@ -972,7 +972,7 @@ public URL getResource(String name) { awaitFuture(vertx.deployVerticle(new AbstractVerticle() { @Override public void start(Promise startPromise) { - server = vertx.createHttpServer(getHttpServerOptions()); + server = vertx.createHttpServer(getHttpServerOptions(getServerPort())); server.requestHandler(router) .listen() .mapEmpty() diff --git a/vertx-web/src/test/java/io/vertx/ext/web/handler/sockjs/SockJSHandlerTest.java b/vertx-web/src/test/java/io/vertx/ext/web/handler/sockjs/SockJSHandlerTest.java index df89765a32..2212eb558b 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/handler/sockjs/SockJSHandlerTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/handler/sockjs/SockJSHandlerTest.java @@ -419,11 +419,11 @@ public void testWebContext() throws Exception { })); wsClient.connect(new WebSocketConnectOptions() - .setPort(8080) + .setPort(getServerPort()) .setURI("/webcontext/websocket")).onComplete(onSuccess( ws -> { wsClient.connect(new WebSocketConnectOptions() - .setPort(8080) + .setPort(getServerPort()) .setURI("/webcontextuser/websocket")).onComplete(onSuccess(wsuser -> complete()) ); } @@ -448,7 +448,7 @@ public void testCookiesRemoved() throws Exception { headers.add("cookie", "flibble=floob"); wsClient.connect(new WebSocketConnectOptions() - .setPort(8080) + .setPort(getServerPort()) .setURI("/cookiesremoved/websocket") .setHeaders(headers)).onComplete(onSuccess(ws -> { complete(); diff --git a/vertx-web/src/test/java/io/vertx/ext/web/sstore/ClusteredSessionHandlerTest.java b/vertx-web/src/test/java/io/vertx/ext/web/sstore/ClusteredSessionHandlerTest.java index ae0c18da86..681fe69539 100644 --- a/vertx-web/src/test/java/io/vertx/ext/web/sstore/ClusteredSessionHandlerTest.java +++ b/vertx-web/src/test/java/io/vertx/ext/web/sstore/ClusteredSessionHandlerTest.java @@ -82,7 +82,7 @@ public void testClusteredSession() throws Exception { SessionStore store1 = ClusteredSessionStore.create(vertices[0]); SessionHandler sessionHandler1 = SessionHandler.create(store1); router1.route().handler(sessionHandler1); - servers[0] = vertices[0].createHttpServer(new HttpServerOptions().setPort(8081).setHost("localhost")); + servers[0] = vertices[0].createHttpServer(new HttpServerOptions().setPort(getServerPort() + 1).setHost("localhost")); servers[0].requestHandler(router1); servers[0].listen().onComplete(onSuccess(s -> serversReady.countDown())); @@ -90,7 +90,7 @@ public void testClusteredSession() throws Exception { SessionStore store2 = ClusteredSessionStore.create(vertices[1]); SessionHandler sessionHandler2 = SessionHandler.create(store2); router2.route().handler(sessionHandler2); - servers[1] = vertices[1].createHttpServer(new HttpServerOptions().setPort(8082).setHost("localhost")); + servers[1] = vertices[1].createHttpServer(new HttpServerOptions().setPort(getServerPort() + 2).setHost("localhost")); servers[1].requestHandler(router2); servers[1].listen().onComplete(onSuccess(s -> serversReady.countDown())); @@ -98,7 +98,7 @@ public void testClusteredSession() throws Exception { SessionStore store3 = ClusteredSessionStore.create(vertices[2]); SessionHandler sessionHandler3 = SessionHandler.create(store3); router3.route().handler(sessionHandler3); - servers[2] = vertices[2].createHttpServer(new HttpServerOptions().setPort(8083).setHost("localhost")); + servers[2] = vertices[2].createHttpServer(new HttpServerOptions().setPort(getServerPort() + 3).setHost("localhost")); servers[2].requestHandler(router3); servers[2].listen().onComplete(onSuccess(s -> serversReady.countDown())); @@ -155,12 +155,12 @@ public void testClusteredSession() throws Exception { }); AtomicReference rSetCookie = new AtomicReference<>(); - testRequestBuffer(client, HttpMethod.GET, 8081, "/", null, resp -> { + testRequestBuffer(client, HttpMethod.GET, getServerPort() + 1, "/", null, resp -> { String setCookie = resp.headers().get("set-cookie"); rSetCookie.set(setCookie); }, 200, "OK", null); - testRequestBuffer(client, HttpMethod.GET, 8082, "/", req -> req.putHeader("cookie", rSetCookie.get()), null, 200, "OK", null); - testRequestBuffer(client, HttpMethod.GET, 8083, "/", req -> req.putHeader("cookie", rSetCookie.get()), null, 200, "OK", null); + testRequestBuffer(client, HttpMethod.GET, getServerPort() + 2, "/", req -> req.putHeader("cookie", rSetCookie.get()), null, 200, "OK", null); + testRequestBuffer(client, HttpMethod.GET, getServerPort() + 3, "/", req -> req.putHeader("cookie", rSetCookie.get()), null, 200, "OK", null); } @Test @@ -246,7 +246,7 @@ public void testDelayedLookupWithRequestUpgrade() throws InterruptedException { router1.route() .handler(sessionHandler1) .handler(upgradeHandler); - servers[0] = vertices[0].createHttpServer(new HttpServerOptions().setPort(8081).setHost("localhost")); + servers[0] = vertices[0].createHttpServer(new HttpServerOptions().setPort(getServerPort() + 1).setHost("localhost")); servers[0].requestHandler(router1); servers[0].listen().onComplete(onSuccess(s -> serversReady.countDown())); @@ -256,7 +256,7 @@ public void testDelayedLookupWithRequestUpgrade() throws InterruptedException { router1.route() .handler(sessionHandler2) .handler(upgradeHandler); - servers[1] = vertices[1].createHttpServer(new HttpServerOptions().setPort(8082).setHost("localhost")); + servers[1] = vertices[1].createHttpServer(new HttpServerOptions().setPort(getServerPort() + 2).setHost("localhost")); servers[1].requestHandler(router2); servers[1].listen().onComplete(onSuccess(s -> serversReady.countDown())); @@ -266,7 +266,7 @@ public void testDelayedLookupWithRequestUpgrade() throws InterruptedException { router1.route() .handler(sessionHandler3) .handler(upgradeHandler); - servers[2] = vertices[2].createHttpServer(new HttpServerOptions().setPort(8083).setHost("localhost")); + servers[2] = vertices[2].createHttpServer(new HttpServerOptions().setPort(getServerPort() + 3).setHost("localhost")); servers[2].requestHandler(router3); servers[2].listen().onComplete(onSuccess(s -> serversReady.countDown())); @@ -275,7 +275,7 @@ public void testDelayedLookupWithRequestUpgrade() throws InterruptedException { WebSocketConnectOptions options1 = new WebSocketConnectOptions() .setURI("/") - .setPort(8081) + .setPort(getServerPort() + 1) .setHost("localhost") .addHeader("cookie", sessionCookieName + "=" + TestUtils.randomAlphaString(32)); @@ -288,7 +288,7 @@ public void testDelayedLookupWithRequestUpgrade() throws InterruptedException { WebSocketConnectOptions options2 = new WebSocketConnectOptions() .setURI("/") - .setPort(8081) + .setPort(getServerPort() + 1) .setHost("localhost") .addHeader("cookie", sessionCookieName + "=" + TestUtils.randomAlphaString(32)); @@ -301,7 +301,7 @@ public void testDelayedLookupWithRequestUpgrade() throws InterruptedException { WebSocketConnectOptions options3 = new WebSocketConnectOptions() .setURI("/") - .setPort(8081) + .setPort(getServerPort() + 1) .setHost("localhost") .addHeader("cookie", sessionCookieName + "=" + TestUtils.randomAlphaString(32));