use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class SessionExampleHandlerTest method invalidMethod.
@Test
public void invalidMethod() {
final SessionExampleHandler handler = new SessionExampleHandler(Executors.newCachedThreadPool());
final HttpRequest request = HttpRequest.createTestRequest(URI, GET);
HttpResponse response = handler.handle(request);
assertThat(response.getStatus(), is(METHOD_NOT_ALLOWED));
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class SessionExampleHandlerTest method basicPut.
@Test
public void basicPut() throws IOException {
final SessionExampleHandler handler = new SessionExampleHandler(Executors.newCachedThreadPool());
final HttpRequest request = HttpRequest.createTestRequest(URI, PUT);
HttpResponse response = handler.handle(request);
assertThat(response.getStatus(), is(OK));
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"test\":\"PUT received\"}"));
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class HttpGetConfigHandlerTest method require_that_request_gets_correct_fields_with_full_appid.
@Test
public void require_that_request_gets_correct_fields_with_full_appid() {
String uriLongAppId = "http://yahoo.com:8080/config/v2/tenant/bill/application/sookie/environment/dev/region/bellefleur/instance/sam/foo.bar/myid";
HttpRequest r = HttpRequest.createTestRequest(uriLongAppId, GET);
HttpConfigRequest req = HttpConfigRequest.createFromRequestV2(r);
assertThat(req.getApplicationId().tenant().value(), is("bill"));
assertThat(req.getApplicationId().application().value(), is("sookie"));
assertThat(req.getApplicationId().instance().value(), is("sam"));
}
use of com.yahoo.container.jdisc.HttpRequest 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(ApplicationId.defaultId(), 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("{\"boolval\":false,\"doubleval\":0.0,\"enumval\":\"VAL1\",\"intval\":0,\"longval\":0,\"stringval\":\"s\"}"));
}
use of com.yahoo.container.jdisc.HttpRequest 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/v1/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/v1/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/v1/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/");
}
Aggregations