use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class HttpListConfigsHandlerTest method require_that_named_handler_can_be_created.
@Test
public void require_that_named_handler_can_be_created() throws IOException {
HttpRequest req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/foo.bar/conf/id/", GET);
req.getJDiscRequest().parameters().put("http.path", Arrays.asList("foo.bar"));
HttpResponse response = namedHandler.handle(req);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"children\":[],\"configs\":[]}"));
}
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/v2/tenant/mytenant/application/myapplication/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/v2/tenant/mytenant/application/myapplication/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/v2/tenant/mytenant/application/myapplication/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");
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class HttpListConfigsHandlerTest method require_that_named_handler_can_be_created_from_full_appid.
@Test
public void require_that_named_handler_can_be_created_from_full_appid() throws IOException {
HttpRequest req = HttpRequest.createTestRequest("http://foo.com:8080/config/v2/tenant/mytenant/application/myapplication/environment/prod/region/myregion/instance/myinstance/foo.bar/conf/id/", GET);
req.getJDiscRequest().parameters().put("http.path", Arrays.asList("foo.bar"));
HttpResponse response = namedHandler.handle(req);
assertThat(SessionHandlerTest.getRenderedString(response), is("{\"children\":[],\"configs\":[]}"));
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class SessionCreateHandlerTest method assertIllegalFromParameter.
private void assertIllegalFromParameter(String fromValue) throws IOException {
File outFile = CompressedApplicationInputStreamTest.createTarFile();
HttpRequest request = post(outFile, postHeaders, Collections.singletonMap("from", fromValue));
HandlerTest.assertHttpStatusCodeErrorCodeAndMessage(createHandler().handle(request), BAD_REQUEST, HttpErrorResponse.errorCodes.BAD_REQUEST, "Parameter 'from' has illegal value '" + fromValue + "'");
}
use of com.yahoo.container.jdisc.HttpRequest in project vespa by vespa-engine.
the class QueryProfileIntegrationTestCase method testTyped.
public void testTyped() {
String configId = "dir:src/test/java/com/yahoo/search/query/profile/config/test/typed";
System.setProperty("config.id", configId);
Container container = new Container();
HandlersConfigurerTestWrapper configurer = new HandlersConfigurerTestWrapper(container, configId);
SearchHandler searchHandler = (SearchHandler) configurer.getRequestHandlerRegistry().getComponent(SearchHandler.class.getName());
// Should get "default" query profile containing the "test" search chain containing the "test" searcher
HttpRequest request = HttpRequest.createTestRequest("search", Method.GET);
// Cast to access content directly
HttpSearchResponse response = (HttpSearchResponse) searchHandler.handle(request);
assertNotNull(response.getResult().hits().get("from:test"));
// Should get the "test' query profile containing the "default" search chain containing the "default" searcher
request = HttpRequest.createTestRequest("search?queryProfile=test", Method.GET);
// Cast to access content directly
response = (HttpSearchResponse) searchHandler.handle(request);
assertNotNull(response.getResult().hits().get("from:default"));
// Should get "default" query profile, but override the search chain to default
request = HttpRequest.createTestRequest("search?searchChain=default", Method.GET);
// Cast to access content directly
response = (HttpSearchResponse) searchHandler.handle(request);
assertNotNull(response.getResult().hits().get("from:default"));
// Tests a profile setting hits and offset
request = HttpRequest.createTestRequest("search?queryProfile=hitsoffset", Method.GET);
// Cast to access content directly
response = (HttpSearchResponse) searchHandler.handle(request);
assertEquals(22, response.getQuery().getHits());
assertEquals(80, response.getQuery().getOffset());
// Tests a non-resolved profile request
request = HttpRequest.createTestRequest("search?queryProfile=none", Method.GET);
// Cast to access content directly
response = (HttpSearchResponse) searchHandler.handle(request);
assertNotNull("Got an error", response.getResult().hits().getError());
assertEquals("Could not resolve query profile 'none'", response.getResult().hits().getError().getDetailedMessage());
// Test overriding a sub-profile in the request
request = HttpRequest.createTestRequest("search?queryProfile=root&sub=newsub", Method.GET);
// Cast to access content directly
response = (HttpSearchResponse) searchHandler.handle(request);
assertEquals("newsubvalue1", response.getQuery().properties().get("sub.value1"));
assertEquals("newsubvalue2", response.getQuery().properties().get("sub.value2"));
configurer.shutdown();
}
Aggregations