Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable server port for the tests #2513

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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();
}));
Expand All @@ -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<JsonObject> 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<JsonObject> values = compositeFuture.list();
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 } }");
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<String> expected = testData.urls().stream()
.filter(url -> url.startsWith("https://"))
.collect(toList());
Expand All @@ -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<String> expected = testData.urls().stream()
.filter(url -> url.startsWith("https://"))
.collect(toList());
Expand All @@ -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<String> expected = Arrays.asList(descriptions);
Expand All @@ -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 {
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ GraphQLRequest setInitialValue(Object initialValue) {
return this;
}

void send(HttpClient client, Handler<AsyncResult<JsonObject>> handler) throws Exception {
send(client, 200, handler);
void send(HttpClient client, int serverPort, Handler<AsyncResult<JsonObject>> handler) throws Exception {
send(client, 200, serverPort, handler);
}

void send(HttpClient client, int expectedStatus, Handler<AsyncResult<JsonObject>> handler) throws Exception {
void send(HttpClient client, int expectedStatus, int serverPort, Handler<AsyncResult<JsonObject>> handler) throws Exception {
Promise<JsonObject> promise = Promise.promise();
promise.future().onComplete(handler);
Future<HttpClientRequest> fut = client.request(method, 8080, "localhost", getUri());
Future<HttpClientRequest> fut = client.request(method, serverPort, "localhost", getUri());
fut.onComplete(ar1 -> {
if (ar1.succeeded()) {
HttpClientRequest request = ar1.result();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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()
Expand All @@ -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()
Expand Down
Loading