use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpListConfigsHandlerTest method require_error_on_bad_request.
@Test
public void require_error_on_bad_request() throws IOException {
HttpRequest req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/foobar/conf/id/", GET);
HttpResponse resp = namedHandler.handle(req);
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(resp, BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Illegal config, must be of form namespace.name.");
req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/foo.barNOPE/conf/id/", GET);
resp = namedHandler.handle(req);
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(resp, NOT_FOUND, HttpErrorResponse.errorCodes.NOT_FOUND, "No such config: foo.barNOPE");
req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/foo.bar/conf/id/NOPE/", GET);
resp = namedHandler.handle(req);
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(resp, NOT_FOUND, HttpErrorResponse.errorCodes.NOT_FOUND, "No such config id: conf/id/NOPE");
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpListConfigsHandlerTest method require_that_request_can_be_created_from_full_appid.
@Test
public void require_that_request_can_be_created_from_full_appid() throws IOException {
HttpResponse response = handler.handle(HttpRequest.createTestRequest("http://yahoo.com:8080/config/v2/tenant/mytenant/application/myapplication/environment/test/region/myregion/instance/myinstance/", GET));
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"children\":[],\"configs\":[]}"));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpListConfigsHandlerTest method require_that_named_handler_can_be_created_from_full_appid.
@Test
public void require_that_named_handler_can_be_created_from_full_appid() throws IOException {
HttpRequest req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/environment/prod/region/myregion/instance/myinstance/foo.bar/conf/id/", GET);
req.getJDiscRequest().parameters().put("http.path", Arrays.asList("foo.bar"));
HttpResponse response = namedHandler.handle(req);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"children\":[],\"configs\":[]}"));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testActivationOfUnpreparedSession.
@Test
public void testActivationOfUnpreparedSession() throws Exception {
Clock clock = Clock.systemUTC();
// Needed so we can test that previous active session is still active after a failed activation
RemoteSession firstSession = activateAndAssertOK(90l, 0l, clock);
long sessionId = 91L;
ActivateRequest activateRequest = new ActivateRequest(sessionId, 0l, Session.Status.NEW, "", clock).invoke();
HttpResponse actResponse = activateRequest.getActResponse();
RemoteSession session = activateRequest.getSession();
assertThat(actResponse.getStatus(), is(Response.Status.BAD_REQUEST));
assertThat(getRenderedString(actResponse), is("{\"error-code\":\"BAD_REQUEST\",\"message\":\"tenant:" + tenant + " app:default:default Session " + sessionId + " is not prepared\"}"));
assertThat(session.getStatus(), is(not(Session.Status.ACTIVATE)));
assertThat(firstSession.getStatus(), is(Session.Status.ACTIVATE));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testAlreadyActivatedSession.
@Test
public void testAlreadyActivatedSession() throws Exception {
activateAndAssertOK(1, 0, Clock.systemUTC());
HttpResponse response = createHandler().handle(SessionHandlerTest.createTestRequest(pathPrefix, HttpRequest.Method.PUT, Cmd.ACTIVE, 1l));
String message = getRenderedString(response);
assertThat(message, response.getStatus(), Is.is(BAD_REQUEST));
assertThat(message, containsString("Session 1 is already active"));
}
Aggregations