use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method require_that_session_created_from_active_that_is_no_longer_active_cannot_be_activated.
@Test
public void require_that_session_created_from_active_that_is_no_longer_active_cannot_be_activated() throws Exception {
Clock clock = Clock.systemUTC();
long sessionId = 1;
activateAndAssertOK(1, 0, clock);
sessionId++;
activateAndAssertOK(sessionId, 1, clock);
sessionId++;
ActivateRequest activateRequest = new ActivateRequest(sessionId, 1, "", Clock.systemUTC()).invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
assertThat(message, actResponse.getStatus(), Is.is(CONFLICT));
assertThat(message, containsString("Cannot activate session 3 because the currently active session (2) has changed since session 3 was created (was 1 at creation time)"));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpProxyTest method testFetchException.
@Test(expected = RequestTimeoutException.class)
public void testFetchException() {
when(fetcher.get(any(), any())).thenThrow(new RequestTimeoutException("timed out"));
HttpResponse actualResponse = proxy.get(applicationMock, hostname, "container-clustercontroller", "clustercontroller-status/v1/clusterName");
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ContentHandlerTestBase method require_that_nonexistant_file_returns_not_found.
@Test
public void require_that_nonexistant_file_returns_not_found() throws IOException {
HttpResponse response = doRequest(HttpRequest.Method.GET, "/test2.txt");
assertNotNull(response);
assertThat(response.getStatus(), is(NOT_FOUND));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ContentHandlerTestBase method assertStatus.
protected void assertStatus(String path, String expectedContent) throws IOException {
HttpResponse response = doRequest(HttpRequest.Method.GET, path);
assertNotNull(response);
final String renderedString = SessionHandlerTest.getRenderedString(response);
assertThat(renderedString, response.getStatus(), is(OK));
assertThat(renderedString, is(expectedContent));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpHandlerTest method testResponse.
@Test
public void testResponse() throws IOException {
final String message = "failed";
HttpHandler httpHandler = new HttpTestHandler(new InvalidApplicationException(message));
HttpResponse response = httpHandler.handle(HttpRequest.createTestRequest("foo", com.yahoo.jdisc.http.HttpRequest.Method.GET));
assertThat(response.getStatus(), is(Response.Status.BAD_REQUEST));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
response.render(baos);
Slime data = new Slime();
new JsonDecoder().decode(data, baos.toByteArray());
assertThat(data.get().field("error-code").asString(), is(HttpErrorResponse.errorCodes.INVALID_APPLICATION_PACKAGE.name()));
assertThat(data.get().field("message").asString(), is(message));
}
Aggregations