Search in sources :

Example 91 with HttpResponse

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);
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse)

Example 92 with HttpResponse

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);
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) SessionTest(com.yahoo.vespa.config.server.session.SessionTest) Test(org.junit.Test)

Example 93 with HttpResponse

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));
}
Also used : RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) HttpResponse(com.yahoo.container.jdisc.HttpResponse) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Example 94 with HttpResponse

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");
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse)

Example 95 with HttpResponse

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));
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse) MockCurator(com.yahoo.vespa.curator.mock.MockCurator) HandlerTest(com.yahoo.vespa.config.server.http.HandlerTest) SessionHandlerTest(com.yahoo.vespa.config.server.http.SessionHandlerTest) SessionTest(com.yahoo.vespa.config.server.session.SessionTest) Test(org.junit.Test)

Aggregations

HttpResponse (com.yahoo.container.jdisc.HttpResponse)103 Test (org.junit.Test)75 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)33 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)24 HttpRequest (com.yahoo.container.jdisc.HttpRequest)16 CompressedApplicationInputStreamTest (com.yahoo.vespa.config.server.http.CompressedApplicationInputStreamTest)6 SessionTest (com.yahoo.vespa.config.server.session.SessionTest)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 SimpletypesConfig (com.yahoo.config.SimpletypesConfig)5 InnerCNode (com.yahoo.config.codegen.InnerCNode)5 Slime (com.yahoo.slime.Slime)5 ConfigPayload (com.yahoo.vespa.config.ConfigPayload)5 OutputStream (java.io.OutputStream)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 ApplicationId (com.yahoo.config.provision.ApplicationId)4 IOException (java.io.IOException)4 InputStream (java.io.InputStream)4 HashMap (java.util.HashMap)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3