use of com.yahoo.vespa.config.server.http.StaticResponse in project vespa by vespa-engine.
the class ApplicationHandlerTest method testClusterControllerStatus.
@Test
public void testClusterControllerStatus() throws Exception {
long sessionId = 1;
ApplicationId application = new ApplicationId.Builder().applicationName(ApplicationName.defaultName()).tenant(mytenantName).build();
addMockApplication(tenants.getTenant(mytenantName), application, sessionId, Clock.systemUTC());
String host = "foo.yahoo.com";
String url = toUrlPath(application, Zone.defaultZone(), true) + "/clustercontroller/" + host + "/status/v1/clusterName1";
when(mockHttpProxy.get(any(), eq(host), eq("container-clustercontroller"), eq("clustercontroller-status/v1/clusterName1"))).thenReturn(new StaticResponse(200, "text/html", "<html>...</html>"));
HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(url, com.yahoo.jdisc.http.HttpRequest.Method.GET));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "text/html", "<html>...</html>");
}
use of com.yahoo.vespa.config.server.http.StaticResponse 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