use of org.asynchttpclient.test.TestUtils.AsyncCompletionHandlerAdapter in project async-http-client by AsyncHttpClient.
the class BasicHttpTest method getWithHeaders.
@Test
public void getWithHeaders() throws Throwable {
withClient().run(client -> {
withServer(server).run(server -> {
HttpHeaders h = new DefaultHttpHeaders();
for (int i = 1; i < 5; i++) {
h.add("Test" + i, "Test" + i);
}
server.enqueueEcho();
client.executeRequest(get(getTargetUrl()).setHeaders(h), new AsyncCompletionHandlerAdapter() {
@Override
public Response onCompleted(Response response) throws Exception {
assertEquals(response.getStatusCode(), 200);
for (int i = 1; i < 5; i++) {
assertEquals(response.getHeader("X-Test" + i), "Test" + i);
}
return response;
}
}).get(TIMEOUT, SECONDS);
});
});
}
Aggregations