use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class MockHttpHandler method handle.
@Override
public HttpResponse handle(HttpRequest request) {
return new HttpResponse(200) {
@Override
public void render(OutputStream outputStream) throws IOException {
PrintStream out = new PrintStream(outputStream);
out.print("OK");
out.flush();
}
};
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionExampleHandlerTest method invalidMethod.
@Test
public void invalidMethod() {
final SessionExampleHandler handler = new SessionExampleHandler(Executors.newCachedThreadPool());
final HttpRequest request = HttpRequest.createTestRequest(URI, GET);
HttpResponse response = handler.handle(request);
assertThat(response.getStatus(), is(METHOD_NOT_ALLOWED));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionExampleHandlerTest method basicPut.
@Test
public void basicPut() throws IOException {
final SessionExampleHandler handler = new SessionExampleHandler(Executors.newCachedThreadPool());
final HttpRequest request = HttpRequest.createTestRequest(URI, PUT);
HttpResponse response = handler.handle(request);
assertThat(response.getStatus(), is(OK));
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"test\":\"PUT received\"}"));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class StatusHandlerTest method require_that_handler_works.
@Test
public void require_that_handler_works() throws IOException {
TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder().build();
StatusHandler handler = new StatusHandler(StatusHandler.testOnlyContext(), componentRegistry);
HttpResponse response = handler.handle(HttpRequest.createTestRequest("/status", GET));
JsonNode jsonNode = mapper.readTree(SessionHandlerTest.getRenderedString(response));
ConfigserverConfig expectedConfig = componentRegistry.getConfigserverConfig();
assertEquals(expectedConfig.rpcport(), jsonNode.get("configserverConfig").get("rpcport").asInt());
assertEquals(expectedConfig.applicationDirectory(), jsonNode.get("configserverConfig").get("applicationDirectory").asText());
assertEquals(1, jsonNode.get("modelVersions").size());
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ApplicationHandlerTest method testClusterControllerStatus.
@Test
public void testClusterControllerStatus() throws Exception {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId, Clock.systemUTC());
String host = "foo.yahoo.com";
String url = toUrlPath(application, Zone.defaultZone(), true) + "/clustercontroller/" + host + "/status/v1/clusterName1";
when(mockHttpProxy.get(any(), eq(host), eq("container-clustercontroller"), eq("clustercontroller-status/v1/clusterName1"))).thenReturn(new StaticResponse(200, "text/html", "<html>...</html>"));
HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>...</html>");
}
Aggregations