use of io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder in project smallrye-graphql by smallrye.
the class DynamicClientSSLTest method clientAuthentication_correctKeystore.
/**
* Server requests client authentication.
*/
@Test
public void clientAuthentication_correctKeystore() throws Exception {
HttpServer server = tools.runServer("classpath:ssl/server.pkcs12.keystore", "serverkeystorepassword", "classpath:ssl/server.pkcs12.truststore", "servertruststorepassword");
try {
System.setProperty("myclient3/mp-graphql/keystore", "classpath:ssl/client.pkcs12.keystore");
System.setProperty("myclient3/mp-graphql/keystorePassword", "clientkeystorepassword");
System.setProperty("myclient3/mp-graphql/keystoreType", "PKCS12");
WebClientOptions options = new WebClientOptions();
// don't require server auth
options.setTrustAll(true);
DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().configKey("myclient3").options(options).url("https://127.0.0.1:" + server.actualPort()).build();
client.executeAsync("asd").await().atMost(Duration.ofSeconds(1));
client.close();
} finally {
server.close();
}
}
use of io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder in project smallrye-graphql by smallrye.
the class RecordAsInputToDynamicClientTest method testSimpleRecord.
@Test
public void testSimpleRecord() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().url(testingURL.toString() + "graphql").build()) {
Response response = client.executeSync("query { simple {a b} }");
SimpleRecord result = response.getObject(SimpleRecord.class, "simple");
assertEquals("a", result.a());
assertEquals("b", result.b());
}
}
use of io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder in project smallrye-graphql by smallrye.
the class RecordAsInputToDynamicClientTest method testPartial.
/**
* Try selecting only a subset of fields supported by the record.
*/
@Test
public void testPartial() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().url(testingURL.toString() + "graphql").build()) {
Response response = client.executeSync("query { simple {a} }");
SimpleRecord result = response.getObject(SimpleRecord.class, "simple");
assertEquals("a", result.a());
assertNull(result.b());
}
}
use of io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder in project smallrye-graphql by smallrye.
the class RecordAsInputToDynamicClientTest method testReversed.
/**
* Just to be sure that if I reverse the order of fields in the query,
* they won't get mixed up on the client side.
*/
@Test
public void testReversed() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().url(testingURL.toString() + "graphql").build()) {
Response response = client.executeSync("query { simple {b a} }");
SimpleRecord result = response.getObject(SimpleRecord.class, "simple");
assertEquals("a", result.a());
assertEquals("b", result.b());
}
}
use of io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder in project smallrye-graphql by smallrye.
the class SubscriptionInitializationTimeoutTest method test.
@Test
public void test() throws ExecutionException, InterruptedException, TimeoutException {
HttpServer server = runMockServer();
try {
DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().subprotocols(WebsocketSubprotocol.GRAPHQL_TRANSPORT_WS).websocketInitializationTimeout(100).url("http://localhost:" + server.actualPort()).build();
Uni<Throwable> testFinish = Uni.createFrom().emitter(emitter -> {
Multi<Response> subscriptionMulti = client.subscription("{}");
subscriptionMulti.subscribe().with(item -> {
emitter.complete(null);
}, failure -> {
emitter.complete(failure);
});
});
Throwable testResult = testFinish.await().atMost(Duration.ofSeconds(3));
Assertions.assertNotNull(testResult);
Assertions.assertTrue(testResult.getMessage().contains("Server did not send a connection_ack message"), testResult.getMessage());
} finally {
server.close();
}
}
Aggregations