use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HostHandlerTest method deleteAndAssertResponse.
private void deleteAndAssertResponse(String url, int expectedStatus, HttpErrorResponse.errorCodes errorCode, String expectedResponse, com.yahoo.jdisc.http.HttpRequest.Method method) throws IOException {
HttpResponse response = handler.handle(HttpRequest.createTestRequest(url, method));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, expectedStatus, errorCode, expectedResponse);
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testUnknownSession.
@Test
public void testUnknownSession() throws Exception {
HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.ACTIVE, 9999L, "?timeout=1.0"));
assertEquals(response.getStatus(), 404);
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method activateAndAssertErrorPut.
private void activateAndAssertErrorPut(long sessionId, long previousSessionId, Clock clock, int statusCode, HttpErrorResponse.errorCodes errorCode, String expectedError) throws Exception {
ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, "", clock);
activateRequest.invoke();
HttpResponse actResponse = activateRequest.getActResponse();
RemoteSession session = activateRequest.getSession();
assertThat(actResponse.getStatus(), Is.is(statusCode));
String message = getRenderedString(actResponse);
assertThat(message, Is.is("{\"error-code\":\"" + errorCode.name() + "\",\"message\":\"" + expectedError + "\"}"));
assertThat(session.getStatus(), Is.is(Session.Status.PREPARE));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testUnsupportedMethod.
private void testUnsupportedMethod(com.yahoo.container.jdisc.HttpRequest request) throws Exception {
HttpResponse response = createHandler().handle(request);
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, METHOD_NOT_ALLOWED, HttpErrorResponse.errorCodes.METHOD_NOT_ALLOWED, "Method '" + request.getMethod().name() + "' is not supported");
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testActivationWithBarrierTimeout.
@Test
public void testActivationWithBarrierTimeout() throws Exception {
// Needed so we can test that previous active session is still active after a failed activation
activateAndAssertOK(90l, 0l, Clock.systemUTC());
((MockCurator) curator).timeoutBarrierOnEnter(true);
ActivateRequest activateRequest = new ActivateRequest(91l, 90l, "", Clock.systemUTC()).invoke();
HttpResponse actResponse = activateRequest.getActResponse();
assertThat(actResponse.getStatus(), Is.is(INTERNAL_SERVER_ERROR));
}
Aggregations