use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class SearchHandlerTestCase method testFailedReconfiguration.
@Test
// TODO: Must be done at the ConfiguredApplication level, not handlers configurer? Also, this must be rewritten as the above
@Ignore
public synchronized void testFailedReconfiguration() throws Exception {
assertXmlResult(driver);
// attempt reconfiguration
IOUtils.copyDirectory(new File(testDir, "handlersInvalid"), new File(tempDir), 1);
generateComponentsConfigForActive();
configurer.reloadConfig();
SearchHandler newSearchHandler = fetchSearchHandler(configurer);
RequestHandler newMockHandler = configurer.getRequestHandlerRegistry().getComponent("com.yahoo.search.handler.test.MockHandler");
assertTrue("Reconfiguration failed: Kept the existing instance of the search handler", searchHandler == newSearchHandler);
assertNull("Reconfiguration failed: No mock handler", newMockHandler);
try (RequestHandlerTestDriver newDriver = new RequestHandlerTestDriver(searchHandler)) {
assertXmlResult(newDriver);
}
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class SearchHandlerTestCase method assertHandlerResponse.
private void assertHandlerResponse(int status, String responseData, String handlerName) throws Exception {
RequestHandler forwardingHandler = configurer.getRequestHandlerRegistry().getComponent("com.yahoo.search.handler.test.SearchHandlerTestCase$" + handlerName + "Handler");
try (RequestHandlerTestDriver forwardingDriver = new RequestHandlerTestDriver(forwardingHandler)) {
RequestHandlerTestDriver.MockResponseHandler response = forwardingDriver.sendRequest("http://localhost/" + handlerName + "?query=test");
response.awaitResponse();
assertEquals("Expected HTTP status", status, response.getStatus());
if (responseData == null)
assertEquals("Connection closed with no data", null, response.read());
else
assertEquals(responseData, response.readAll());
}
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatPatternResolutionWorksForWildCards.
@Test
public void requireThatPatternResolutionWorksForWildCards() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host:*/bar"), foo);
RequestHandler bob = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://*abc:*/*bar"), bob);
RequestHandler car = new NonWorkingRequestHandler();
handlers.put(new UriPattern("*://*:21/*"), car);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
BindingMatch<RequestHandler> match = bindings.match(URI.create("http://host:8080/bar"));
assertNotNull(match);
assertEquals(1, match.groupCount());
assertEquals("8080", match.group(0));
assertSame(foo, match.target());
assertSame(foo, bindings.resolve(URI.create("http://host:8080/bar")));
match = bindings.match(URI.create("http://host:8080/foo/bar"));
assertNull(match);
match = bindings.match(URI.create("http://xyzabc:8080/pqrbar"));
assertNotNull(match);
assertSame(bob, match.target());
match = bindings.match(URI.create("ftp://lmn:21/abc"));
assertNotNull(match);
assertSame(car, match.target());
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatTreeSplitCanBeBoundForWildcards.
@Test
public void requireThatTreeSplitCanBeBoundForWildcards() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo8080 = new NonWorkingRequestHandler();
RequestHandler foo80 = new NonWorkingRequestHandler();
RequestHandler foobar = new NonWorkingRequestHandler();
RequestHandler foopqrbar = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host:8080/foo"), foo8080);
handlers.put(new UriPattern("http://host:708/foo"), foo80);
handlers.put(new UriPattern("http://host:80/foobar"), foobar);
handlers.put(new UriPattern("http://hos*:708/foo"), foopqrbar);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
assertSame(foopqrbar, bindings.resolve(URI.create("http://hostabc:708/foo")));
assertSame(foo80, bindings.resolve(URI.create("http://host:708/foo")));
assertSame(foo8080, bindings.resolve(URI.create("http://host:8080/foo")));
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatPatternResolutionWorksForFilters.
@Test
public void requireThatPatternResolutionWorksForFilters() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://*/filtered/*"), foo);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
BindingMatch<RequestHandler> match = bindings.match(URI.create("http://localhost:80/status.html"));
assertNull(match);
match = bindings.match(URI.create("http://localhost/filtered/status.html"));
assertNotNull(match);
assertSame(foo, match.target());
}
Aggregations