use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatTreeSplitCanBeBoundForPorts.
@Test
public void requireThatTreeSplitCanBeBoundForPorts() {
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:70/foo"), foo80);
handlers.put(new UriPattern("http://hostpqr:70/foo"), foopqrbar);
handlers.put(new UriPattern("http://host:80/foobar"), foobar);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatTreeWorksForURIWithQueryOrFragments.
@Test
public void requireThatTreeWorksForURIWithQueryOrFragments() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://*/application/v1/session"), foo);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
assertSame(foo, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v1/session?name=base")));
assertSame(foo, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v1/session#application")));
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatAccessorsWork.
@Test
public void requireThatAccessorsWork() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host/foo"), foo);
RequestHandler bar = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host/bar"), bar);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
Iterator<Map.Entry<UriPattern, RequestHandler>> it = bindings.iterator();
assertNotNull(it);
assertTrue(it.hasNext());
Map.Entry<UriPattern, RequestHandler> entry = it.next();
assertNotNull(entry);
assertEquals(new UriPattern("http://host/foo"), entry.getKey());
assertSame(foo, entry.getValue());
assertTrue(it.hasNext());
assertNotNull(entry = it.next());
assertEquals(new UriPattern("http://host/bar"), entry.getKey());
assertSame(bar, entry.getValue());
assertFalse(it.hasNext());
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatTreeSplitCanBeBoundForPaths.
@Test
public void requireThatTreeSplitCanBeBoundForPaths() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler foobar = new NonWorkingRequestHandler();
RequestHandler fooqux = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host/foobar"), foobar);
handlers.put(new UriPattern("http://host/fooqux"), fooqux);
handlers.put(new UriPattern("http://host/foo"), foo);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
}
use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatStrictPatternsOrderBeforeWildcards.
@Test
public void requireThatStrictPatternsOrderBeforeWildcards() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler fooScheme = new NonWorkingRequestHandler();
RequestHandler barScheme = new NonWorkingRequestHandler();
RequestHandler fooHost = new NonWorkingRequestHandler();
RequestHandler barHost = new NonWorkingRequestHandler();
RequestHandler fooPort = new NonWorkingRequestHandler();
RequestHandler barPort = new NonWorkingRequestHandler();
RequestHandler carPort = new NonWorkingRequestHandler();
RequestHandler fooPath = new NonWorkingRequestHandler();
RequestHandler barPath = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host/x/"), fooScheme);
handlers.put(new UriPattern("*://host/x/"), barScheme);
handlers.put(new UriPattern("http://host/abc/"), fooHost);
handlers.put(new UriPattern("http://*/abc/"), barHost);
handlers.put(new UriPattern("http://host:*/a/"), fooPort);
handlers.put(new UriPattern("http://host:5050/b/"), barPort);
handlers.put(new UriPattern("http://host/b/"), carPort);
handlers.put(new UriPattern("http://hostname/abcde/"), fooPath);
handlers.put(new UriPattern("http://hostname/*/"), barPath);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
assertSame(fooScheme, bindings.resolve(URI.create("http://host/x/")));
assertSame(barScheme, bindings.resolve(URI.create("ftp://host/x/")));
assertSame(fooHost, bindings.resolve(URI.create("http://host:8080/abc/")));
assertSame(barHost, bindings.resolve(URI.create("http://lmn:5050/abc/")));
assertSame(fooPort, bindings.resolve(URI.create("http://host:5050/a/")));
assertSame(barPort, bindings.resolve(URI.create("http://host:5050/b/")));
assertSame(carPort, bindings.resolve(URI.create("http://host/b/")));
assertSame(carPort, bindings.resolve(URI.create("http://host:8080/b/")));
assertSame(carPort, bindings.resolve(URI.create("http://host:80/b/")));
assertSame(fooPath, bindings.resolve(URI.create("http://hostname/abcde/")));
assertSame(barPath, bindings.resolve(URI.create("http://hostname/abcd/")));
}
Aggregations