use of io.helidon.webclient.WebClient in project helidon by oracle.
the class Status204Test method callPutAndGet.
@Test
void callPutAndGet() throws Exception {
WebClient webClient = WebClient.builder().baseUri("http://localhost:" + server.port()).build();
webClient.put().submit("test call").thenAccept(it -> assertThat(it.status(), is(Http.Status.NO_CONTENT_204))).thenCompose(it -> webClient.get().request(String.class)).thenAccept(it -> assertThat(it, is("test"))).toCompletableFuture().get();
}
use of io.helidon.webclient.WebClient in project helidon by oracle.
the class TestHttpParseFineTuning method testDefaults.
@Test
void testDefaults() {
// default is 8Kb for headers
// and 4096 for initial line
WebServer ws = WebServer.builder().host("localhost").routing(Routing.builder().register("/static", StaticContentSupport.create("/static")).any((req, res) -> res.send("any")).build()).build().start().await(10, TimeUnit.SECONDS);
WebClient client = WebClient.builder().baseUri("http://localhost:" + ws.port()).validateHeaders(false).build();
testHeader(client, 8000, true);
testInitialLine(client, 10, true);
testHeader(client, 8900, false);
testHeader(client, 8900, false);
// now test with big initial line
testInitialLine(client, 5000, false);
testHeaderName(client, "X_HEADER", true);
testHeaderName(client, "X\tHEADER", false);
}
use of io.helidon.webclient.WebClient in project helidon by oracle.
the class TestHttpParseFineTuning method testCustom.
@Test
void testCustom() {
Config config = Config.create(ConfigSources.create(Map.of("validate-headers", "false")));
WebServer ws = WebServer.builder().host("localhost").routing(Routing.builder().register("/static", StaticContentSupport.create("/static")).any((req, res) -> res.send("any")).build()).config(config).maxHeaderSize(9100).maxInitialLineLength(5100).build().start().await(10, TimeUnit.SECONDS);
WebClient client = WebClient.builder().baseUri("http://localhost:" + ws.port()).validateHeaders(false).build();
testHeader(client, 8000, true);
testInitialLine(client, 10, true);
testHeader(client, 8900, true);
testHeader(client, 8900, true);
// now test with big initial line
testInitialLine(client, 5000, true);
testHeaderName(client, "X_HEADER", true);
testHeaderName(client, "X\tHEADER", true);
}
use of io.helidon.webclient.WebClient in project helidon by oracle.
the class ResponseOrderingTest method testOrdering.
@Test
public void testOrdering() throws Exception {
WebClient webClient = WebClient.builder().baseUri("http://0.0.0.0:" + webServer.port()).build();
ArrayList<Long> returnedIds = new ArrayList<>();
int i1 = Optional.ofNullable(System.getenv("REQUESTS_COUNT")).map(Integer::valueOf).orElse(10);
for (int i = 0; i < i1; i++) {
webClient.get().path("multi").request(String.class).thenAccept(it -> returnedIds.add(Long.valueOf(it))).toCompletableFuture().get();
}
assertThat(returnedIds.toArray(), allOf(arrayWithSize(i1), is(queue.toArray())));
assertThat("No exceptions expected: " + exceptions(), errorQueue, hasSize(0));
}
use of io.helidon.webclient.WebClient in project helidon by oracle.
the class GraphQlSupportTest method testHelloWorld.
@SuppressWarnings("unchecked")
@Test
void testHelloWorld() {
WebServer server = WebServer.builder().host("localhost").routing(Routing.builder().register(GraphQlSupport.create(buildSchema())).build()).build().start().await(10, TimeUnit.SECONDS);
try {
WebClient webClient = WebClient.builder().addMediaSupport(JsonbSupport.create()).build();
LinkedHashMap<String, Object> response = webClient.post().uri("http://localhost:" + server.port() + "/graphql").submit("{\"query\": \"{hello}\"}", LinkedHashMap.class).await(10, TimeUnit.SECONDS);
Map<String, Object> data = (Map<String, Object>) response.get("data");
assertThat("POST errors: " + response.get("errors"), data, notNullValue());
assertThat("POST", data.get("hello"), is("world"));
response = webClient.get().uri("http://localhost:" + server.port() + "/graphql").queryParam("query", "{hello}").request(LinkedHashMap.class).await(10, TimeUnit.SECONDS);
data = (Map<String, Object>) response.get("data");
assertThat("GET errors: " + response.get("errors"), data, notNullValue());
assertThat("GET", data.get("hello"), is("world"));
} finally {
server.shutdown();
}
}
Aggregations