use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class ApplicationHandlerTest method restart.
private void restart(ApplicationId application, Zone zone) throws IOException {
String restartUrl = toUrlPath(application, zone, true) + "/restart";
HttpResponse response = mockHandler.handle(HttpRequest.createTestRequest(restartUrl, com.yahoo.jdisc.http.HttpRequest.Method.POST));
HandlerTest.assertHttpStatusCodeAndMessage(response, 200, "");
}
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(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").build(), 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(EXPECTED_RENDERED_STRING));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_that_handler_can_handle_long_appid_request_with_configid.
@Test
public void require_that_handler_can_handle_long_appid_request_with_configid() throws IOException {
String uriLongAppId = "http://yahoo.com:8080/config/v2/tenant/" + tenant.value() + "/application/myapplication/environment/staging/region/myregion/instance/myinstance/foo.bar/myid";
final long generation = 1L;
ConfigPayload payload = ConfigPayload.fromInstance(new SimpletypesConfig(new SimpletypesConfig.Builder()));
InnerCNode targetDef = getInnerCNode();
mockRequestHandler.responses.put(new ApplicationId.Builder().tenant(tenant).applicationName("myapplication").instanceName("myinstance").build(), SlimeConfigResponse.fromConfigPayload(payload, targetDef, generation, "mymd5"));
HttpResponse response = handler.handle(HttpRequest.createTestRequest(uriLongAppId, GET));
assertThat(SessionHandlerTest.getRenderedString(response), is(EXPECTED_RENDERED_STRING));
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_correct_error_response.
@Test
public void require_correct_error_response() throws IOException {
final String nonExistingConfigNameUri = "http://yahoo.com:8080/config/v2/tenant/mytenant/application/myapplication/nonexisting.config/myid";
final String nonExistingConfigUri = "http://yahoo.com:8080/config/v2/tenant/mytenant/application/myapplication//foo.bar/myid/nonexisting/id";
final String illegalConfigNameUri = "http://yahoo.com:8080/config/v2/tenant/mytenant/application/myapplication//foobar/myid";
HttpResponse response = handler.handle(HttpRequest.createTestRequest(nonExistingConfigNameUri, GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, NOT_FOUND, HttpErrorResponse.errorCodes.NOT_FOUND, "No such config: nonexisting.config");
assertTrue(SessionHandlerTest.getRenderedString(response).contains("No such config:"));
response = handler.handle(HttpRequest.createTestRequest(nonExistingConfigUri, GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, NOT_FOUND, HttpErrorResponse.errorCodes.NOT_FOUND, "No such config id: myid/nonexisting/id");
assertEquals(response.getContentType(), "application/json");
assertTrue(SessionHandlerTest.getRenderedString(response).contains("No such config id:"));
response = handler.handle(HttpRequest.createTestRequest(illegalConfigNameUri, GET));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(response, BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Illegal config, must be of form namespace.name.");
}
use of com.yahoo.container.jdisc.HttpResponse in project vespa by vespa-engine.
the class SessionContentHandlerTest method require_that_mkdir_with_body_is_illegal.
// TODO: Enable when we have a predictable way of checking request body existence.
@Test
@Ignore
public void require_that_mkdir_with_body_is_illegal() throws IOException {
HttpResponse response = put("/foobio/", "foo");
assertNotNull(response);
assertThat(response.getStatus(), is(Response.Status.BAD_REQUEST));
}
Aggregations