use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method testActivationOfSessionThatDoesNotExistAsLocalSession.
@Test
public void testActivationOfSessionThatDoesNotExistAsLocalSession() throws Exception {
ActivateRequest activateRequest = new ActivateRequest(90l, 0l, "", Clock.systemUTC()).invoke(false);
HttpResponse actResponse = activateRequest.getActResponse();
assertThat(actResponse.getStatus(), Is.is(NOT_FOUND));
String message = getRenderedString(actResponse);
assertThat(message, Is.is("{\"error-code\":\"NOT_FOUND\",\"message\":\"Session 90 was not found\"}"));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionActiveHandlerTest method activateAndAssertOKPut.
private ActivateRequest activateAndAssertOKPut(long sessionId, long previousSessionId, String subPath, Clock clock) throws Exception {
ActivateRequest activateRequest = new ActivateRequest(sessionId, previousSessionId, subPath, clock);
activateRequest.invoke();
HttpResponse actResponse = activateRequest.getActResponse();
String message = getRenderedString(actResponse);
assertThat(message, actResponse.getStatus(), Is.is(OK));
assertActivationMessageOK(activateRequest, message);
RemoteSession session = activateRequest.getSession();
assertThat(session.getStatus(), Is.is(Session.Status.ACTIVATE));
return activateRequest;
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ContentHandlerTestBase method require_that_illegal_return_property_fails.
@Test
public void require_that_illegal_return_property_fails() {
HttpResponse response = doRequest(HttpRequest.Method.GET, "/test.txt?return=foo");
assertThat(response.getStatus(), is(BAD_REQUEST));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ContentHandlerTestBase method assertContent.
protected void assertContent(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 HttpProxyTest method testNormalGet.
@Test
public void testNormalGet() throws Exception {
ArgumentCaptor<HttpFetcher.Params> actualParams = ArgumentCaptor.forClass(HttpFetcher.Params.class);
ArgumentCaptor<URL> actualUrl = ArgumentCaptor.forClass(URL.class);
HttpResponse response = new StaticResponse(200, "application/json", "body");
when(fetcher.get(actualParams.capture(), actualUrl.capture())).thenReturn(response);
HttpResponse actualResponse = proxy.get(applicationMock, hostname, "container-clustercontroller", "clustercontroller-status/v1/clusterName");
assertEquals(1, actualParams.getAllValues().size());
assertEquals(2000, actualParams.getValue().readTimeoutMs);
assertEquals(1, actualUrl.getAllValues().size());
assertEquals(new URL("http://" + hostname + ":" + port + "/clustercontroller-status/v1/clusterName"), actualUrl.getValue());
// The HttpResponse returned by the fetcher IS the same object as the one returned by the proxy,
// when everything goes well.
assertTrue(actualResponse == response);
}
Aggregations