use of io.airlift.http.client.StringResponseHandler.StringResponse in project airlift by airlift.
the class TestJaxrsTestingHttpProcessor method testUndefinedResource.
@Test
public void testUndefinedResource() {
Request request = prepareGet().setUri(URI.create("http://fake.invalid/unknown")).build();
StringResponse response = HTTP_CLIENT.execute(request, createStringResponseHandler());
assertEquals(response.getStatusCode(), 404);
}
use of io.airlift.http.client.StringResponseHandler.StringResponse in project airlift by airlift.
the class TestMBeanResource method testGetHtmlPage.
@Test
public void testGetHtmlPage() {
StringResponse response = client.execute(prepareGet().setUri(uriFor("/v1/jmx")).build(), createStringResponseHandler());
assertEquals(response.getStatusCode(), 200);
assertContentType(response, HTML_UTF_8);
assertContains(response.getBody(), "<html>");
}
use of io.airlift.http.client.StringResponseHandler.StringResponse in project airlift by airlift.
the class TestServer method testOptions.
@Test
public void testOptions() {
StringResponse response = client.execute(new Request.Builder().setMethod("OPTIONS").setUri(uriFor("/v1/person")).build(), createStringResponseHandler());
assertThat(response.getStatusCode()).isEqualTo(HTTP_OK);
assertThat(response.getHeader(CONTENT_TYPE)).isEqualTo("application/vnd.sun.wadl+xml");
assertThat(response.getBody()).startsWith("<?xml ").contains("<application ");
}
use of io.airlift.http.client.StringResponseHandler.StringResponse in project airlift by airlift.
the class AbstractHttpClientTest method testErrorResponseBody.
@Test
public void testErrorResponseBody() throws Exception {
servlet.setResponseStatusCode(500);
servlet.setResponseBody("body text");
Request request = prepareGet().setUri(baseURI).build();
StringResponse response = executeRequest(request, createStringResponseHandler());
assertEquals(response.getStatusCode(), 500);
assertEquals(response.getBody(), "body text");
}
use of io.airlift.http.client.StringResponseHandler.StringResponse in project airlift by airlift.
the class AbstractHttpClientTest method testCompressionIsDisabled.
@Test
public void testCompressionIsDisabled() throws Exception {
Request request = prepareGet().setUri(baseURI).build();
String body = executeRequest(request, createStringResponseHandler()).getBody();
assertEquals(body, "");
assertFalse(servlet.getRequestHeaders().containsKey(HeaderName.of(ACCEPT_ENCODING)));
String json = "{\"fuite\":\"apple\",\"hello\":\"world\"}";
assertGreaterThanOrEqual(json.length(), GzipHandler.DEFAULT_MIN_GZIP_SIZE);
servlet.setResponseBody(json);
servlet.addResponseHeader(CONTENT_TYPE, "application/json");
StringResponse response = executeRequest(request, createStringResponseHandler());
assertEquals(response.getHeader(CONTENT_TYPE), "application/json");
assertEquals(response.getBody(), json);
}
Aggregations