use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatSimpleResolutionWorks.
@Test
public void requireThatSimpleResolutionWorks() {
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());
BindingMatch<RequestHandler> match = bindings.match(URI.create("http://host/foo"));
assertNotNull(match);
assertEquals(0, match.groupCount());
assertSame(foo, match.target());
assertSame(foo, bindings.resolve(URI.create("http://host/foo")));
assertNotNull(match = bindings.match(URI.create("http://host/bar")));
assertEquals(0, match.groupCount());
assertSame(bar, match.target());
assertSame(bar, bindings.resolve(URI.create("http://host/bar")));
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatPatternResolutionWorks.
@Test
public void requireThatPatternResolutionWorks() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host/*"), foo);
RequestHandler bar = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host/path"), bar);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
BindingMatch<RequestHandler> match = bindings.match(URI.create("http://host/anon"));
assertNotNull(match);
assertEquals(1, match.groupCount());
assertEquals("anon", match.group(0));
assertSame(foo, match.target());
assertSame(foo, bindings.resolve(URI.create("http://host/anon")));
assertNotNull(match = bindings.match(URI.create("http://host/path")));
assertEquals(0, match.groupCount());
assertSame(bar, match.target());
assertSame(bar, bindings.resolve(URI.create("http://host/path")));
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler 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.test.NonWorkingRequestHandler 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.test.NonWorkingRequestHandler 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());
}
Aggregations