Search in sources :

Example 1 with VertxDynamicGraphQLClientBuilder

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();
    }
}
Also used : WebClientOptions(io.vertx.ext.web.client.WebClientOptions) HttpServer(io.vertx.core.http.HttpServer) VertxDynamicGraphQLClientBuilder(io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder) DynamicGraphQLClient(io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient) Test(org.junit.jupiter.api.Test)

Example 2 with VertxDynamicGraphQLClientBuilder

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());
    }
}
Also used : Response(io.smallrye.graphql.client.Response) VertxDynamicGraphQLClientBuilder(io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder) DynamicGraphQLClient(io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient) Test(org.junit.Test)

Example 3 with VertxDynamicGraphQLClientBuilder

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());
    }
}
Also used : Response(io.smallrye.graphql.client.Response) VertxDynamicGraphQLClientBuilder(io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder) DynamicGraphQLClient(io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient) Test(org.junit.Test)

Example 4 with VertxDynamicGraphQLClientBuilder

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());
    }
}
Also used : Response(io.smallrye.graphql.client.Response) VertxDynamicGraphQLClientBuilder(io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder) DynamicGraphQLClient(io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient) Test(org.junit.Test)

Example 5 with VertxDynamicGraphQLClientBuilder

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();
    }
}
Also used : Response(io.smallrye.graphql.client.Response) HttpServer(io.vertx.core.http.HttpServer) VertxDynamicGraphQLClientBuilder(io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder) DynamicGraphQLClient(io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient) Test(org.junit.jupiter.api.Test)

Aggregations

DynamicGraphQLClient (io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient)6 VertxDynamicGraphQLClientBuilder (io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder)6 Response (io.smallrye.graphql.client.Response)4 HttpServer (io.vertx.core.http.HttpServer)3 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 WebClientOptions (io.vertx.ext.web.client.WebClientOptions)2