use of org.asynchttpclient.test.TestUtils.AsyncCompletionHandlerAdapter in project async-http-client by AsyncHttpClient.
the class BasicHttpTest method headHasEmptyBody.
@Test
public void headHasEmptyBody() throws Throwable {
withClient().run(client -> {
withServer(server).run(server -> {
server.enqueueOk();
Response response = client.executeRequest(head(getTargetUrl()), new AsyncCompletionHandlerAdapter() {
@Override
public Response onCompleted(Response response) throws Exception {
assertEquals(response.getStatusCode(), 200);
return response;
}
}).get(TIMEOUT, SECONDS);
assertTrue(response.getResponseBody().isEmpty());
});
});
}
use of org.asynchttpclient.test.TestUtils.AsyncCompletionHandlerAdapter in project async-http-client by AsyncHttpClient.
the class BasicHttpTest method getVirtualHost.
@Test
public void getVirtualHost() throws Throwable {
withClient().run(client -> {
withServer(server).run(server -> {
String virtualHost = "localhost:" + server.getHttpPort();
server.enqueueEcho();
Response response = client.prepareGet(getTargetUrl()).setVirtualHost(virtualHost).execute(new AsyncCompletionHandlerAdapter()).get(TIMEOUT, SECONDS);
assertEquals(response.getStatusCode(), 200);
if (response.getHeader("X-" + HOST) == null) {
System.err.println(response);
}
assertEquals(response.getHeader("X-" + HOST), virtualHost);
});
});
}
use of org.asynchttpclient.test.TestUtils.AsyncCompletionHandlerAdapter in project async-http-client by AsyncHttpClient.
the class BasicHttpTest method getRootUrl.
@Test
public void getRootUrl() throws Throwable {
withClient().run(client -> {
withServer(server).run(server -> {
String url = server.getHttpUrl();
server.enqueueOk();
Response response = client.executeRequest(get(url), new AsyncCompletionHandlerAdapter()).get(TIMEOUT, SECONDS);
assertEquals(response.getUri().toUrl(), url);
});
});
}
use of org.asynchttpclient.test.TestUtils.AsyncCompletionHandlerAdapter in project async-http-client by AsyncHttpClient.
the class BasicHttpTest method getUrlWithPathWithoutQuery.
@Test
public void getUrlWithPathWithoutQuery() throws Throwable {
withClient().run(client -> {
withServer(server).run(server -> {
server.enqueueOk();
Response response = client.executeRequest(get(getTargetUrl()), new AsyncCompletionHandlerAdapter()).get(TIMEOUT, SECONDS);
assertEquals(response.getUri().toUrl(), getTargetUrl());
});
});
}
use of org.asynchttpclient.test.TestUtils.AsyncCompletionHandlerAdapter in project async-http-client by AsyncHttpClient.
the class BasicHttpTest method getUrlWithPathWithQueryParams.
@Test
public void getUrlWithPathWithQueryParams() throws Throwable {
withClient().run(client -> {
withServer(server).run(server -> {
server.enqueueOk();
Response response = client.executeRequest(get(getTargetUrl()).addQueryParam("q", "a b"), new AsyncCompletionHandlerAdapter()).get(TIMEOUT, SECONDS);
assertEquals(response.getUri().toUrl(), getTargetUrl() + "?q=a%20b");
});
});
}
Aggregations