use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ApplicationHandlerTest method testFileDistributionStatus.
@Test
public void testFileDistributionStatus() throws Exception {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId, Clock.systemUTC());
Zone zone = Zone.defaultZone();
HttpResponse response = fileDistributionStatus(application, zone);
assertEquals(200, response.getStatus());
SessionHandlerTest.getRenderedString(response);
assertEquals("{\"hosts\":[{\"hostname\":\"mytesthost\",\"status\":\"UNKNOWN\",\"message\":\"error: Connection error(104)\",\"fileReferences\":[]}],\"status\":\"UNKNOWN\"}", SessionHandlerTest.getRenderedString(response));
// 404 for unknown application
ApplicationId unknown = new ApplicationId.Builder().applicationName("unknown").tenant(mytenantName).build();
HttpResponse responseForUnknown = fileDistributionStatus(unknown, zone);
assertEquals(404, responseForUnknown.getStatus());
assertEquals("{\"error-code\":\"NOT_FOUND\",\"message\":\"No such application id: mytenant.unknown\"}", SessionHandlerTest.getRenderedString(responseForUnknown));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_that_handler_can_be_created.
@Test
public void require_that_handler_can_be_created() throws IOException {
// Define config response for mock handler
final long generation = 1L;
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
mockRequestHandler.responses.put(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ListApplicationsHandlerTest method assertResponse.
static void assertResponse(ListApplicationsHandler handler, String url, int expectedStatus, String expectedResponse, Method method) throws IOException {
HttpResponse response = handler.handle(HttpRequest.createTestRequest(url, method));
assertNotNull(response);
assertThat(response.getStatus(), is(expectedStatus));
assertThat(SessionHandlerTest.getRenderedString(response), is(expectedResponse));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionContentHandlerTest method assertWriteFile.
private void assertWriteFile(String path, String content) throws IOException {
HttpResponse response = put(path, content);
assertNotNull(response);
assertThat(response.getStatus(), is(Response.Status.OK));
assertContent(path, content);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"prepared\":\"http://foo:1337" + pathPrefix + "1/prepared\"}"));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionContentHandlerTest method require_that_nonexistant_session_returns_not_found.
@Test
public void require_that_nonexistant_session_returns_not_found() throws IOException {
HttpResponse response = doRequest(HttpRequest.Method.GET, "/test.txt", 2l);
assertNotNull(response);
assertThat(response.getStatus(), is(Response.Status.NOT_FOUND));
}
Aggregations