use of com.yahoo.jdisc.test.NonWorkingRequestHandler 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());
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatToStringMethodWorks.
@Test
public void requireThatToStringMethodWorks() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler bar = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host/foo"), foo);
handlers.put(new UriPattern("http://host/bar"), bar);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
// Just to get code coverage.
assertNotNull(bindings.toString());
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatPathOverPortsDoNotWorkOverStricterPatterns.
@Test
public void requireThatPathOverPortsDoNotWorkOverStricterPatterns() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler bar = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host:4050/a/"), foo);
handlers.put(new UriPattern("http://host/a/"), bar);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
assertSame(foo, bindings.resolve(URI.create("http://host:4050/a/")));
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatPathsAreOrdered.
@Test
public void requireThatPathsAreOrdered() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler bar = new NonWorkingRequestHandler();
RequestHandler car = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host:5050/a/"), foo);
handlers.put(new UriPattern("http://host:5050/b/"), bar);
handlers.put(new UriPattern("http://host/a/"), car);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
assertSame(foo, bindings.resolve(URI.create("http://host:5050/a/")));
assertSame(bar, bindings.resolve(URI.create("http://host:5050/b/")));
assertSame(car, bindings.resolve(URI.create("http://host/a/")));
assertSame(car, bindings.resolve(URI.create("http://host:8080/a/")));
assertSame(car, bindings.resolve(URI.create("http://host:80/a/")));
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatPortsAreOrdered.
@Test
public void requireThatPortsAreOrdered() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler bar = new NonWorkingRequestHandler();
RequestHandler car = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host:5050/a/"), foo);
handlers.put(new UriPattern("http://host:5051/a/"), bar);
handlers.put(new UriPattern("http://host/a/"), car);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
assertSame(foo, bindings.resolve(URI.create("http://host:5050/a/")));
assertSame(bar, bindings.resolve(URI.create("http://host:5051/a/")));
assertSame(car, bindings.resolve(URI.create("http://host/a/")));
assertSame(car, bindings.resolve(URI.create("http://host:8080/a/")));
assertSame(car, bindings.resolve(URI.create("http://host:80/a/")));
}
Aggregations