Search in sources :

Example 16 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method require_that_config_change_actions_are_not_logged_if_not_existing.

@Test
public void require_that_config_change_actions_are_not_logged_if_not_existing() throws Exception {
    MockSession session = new MockSession(1, null);
    localRepo.addSession(session);
    HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
    assertResponseNotContains(response, "Change(s) between active and new application that require restart");
    assertResponseNotContains(response, "Change(s) between active and new application that require re-feed");
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test)

Example 17 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method test_out_of_capacity_response.

@Test
public void test_out_of_capacity_response() throws InterruptedException, IOException {
    String message = "Internal error";
    SessionThrowingException session = new SessionThrowingException(new OutOfCapacityException(message));
    localRepo.addSession(session);
    HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.PREPARED, 1L));
    assertEquals(400, response.getStatus());
    Slime data = getData(response);
    assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.errorCodes.OUT_OF_CAPACITY.name()));
    assertThat(data.get().field("message").asString(), is(message));
}
Also used : OutOfCapacityException(com.yahoo.config.provision.OutOfCapacityException) HttpResponse(com.yahoo.container.jdisc.HttpResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Slime(com.yahoo.slime.Slime) Test(org.junit.Test)

Example 18 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class SessionPrepareHandlerTest method require_error_when_session_id_not_a_number.

@Test
public void require_error_when_session_id_not_a_number() throws Exception {
    final String session = "notanumber/prepared";
    HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix + session));
    assertHttpStatusCodeErrorCodeAndMessage(response, BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Session id in request is not a number, request was 'http://" + hostname + ":" + port + pathPrefix + session + "'");
}
Also used : HttpResponse(com.yahoo.container.jdisc.HttpResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 19 with HttpResponse

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(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
    HttpResponse response = handler.handle(HttpRequest.createTestRequest(configUri, GET));
    assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Also used : SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) HttpResponse(com.yahoo.container.jdisc.HttpResponse) Test(org.junit.Test)

Example 20 with HttpResponse

use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.

the class HttpGetConfigHandlerTest method require_that_nocache_property_works.

@Test
public void require_that_nocache_property_works() throws IOException {
    long generation = 1L;
    ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
    InnerCNode targetDef = getInnerCNode();
    mockRequestHandler.responses.put(ApplicationId.defaultId(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
    final HttpRequest request = HttpRequest.createTestRequest(configUri, GET, null, Collections.singletonMap("nocache", "true"));
    HttpResponse response = handler.handle(request);
    assertThat(SessionHandlerTest.getRenderedString(response), is("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) SimpletypesConfig(com.yahoo.config.SimpletypesConfig) InnerCNode(com.yahoo.config.codegen.InnerCNode) ConfigPayload(com.yahoo.vespa.config.ConfigPayload) HttpResponse(com.yahoo.container.jdisc.HttpResponse) 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