use of com.yahoo.jdisc.test.NonWorkingRequestHandler 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.test.NonWorkingRequestHandler 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/")));
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatTreeWorksForURIWithPathWildCards.
@Test
public void requireThatTreeWorksForURIWithPathWildCards() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler foo1 = new NonWorkingRequestHandler();
RequestHandler foo2 = new NonWorkingRequestHandler();
RequestHandler foo3 = new NonWorkingRequestHandler();
RequestHandler foo4 = new NonWorkingRequestHandler();
RequestHandler foo5 = new NonWorkingRequestHandler();
RequestHandler foo6 = new NonWorkingRequestHandler();
RequestHandler foo7 = new NonWorkingRequestHandler();
RequestHandler foo8 = new NonWorkingRequestHandler();
RequestHandler foo9 = new NonWorkingRequestHandler();
RequestHandler foo10 = new NonWorkingRequestHandler();
RequestHandler foo11 = new NonWorkingRequestHandler();
RequestHandler foo12 = new NonWorkingRequestHandler();
RequestHandler foo13 = new NonWorkingRequestHandler();
RequestHandler foo14 = new NonWorkingRequestHandler();
RequestHandler foo15 = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://*/config/v1/*"), foo);
handlers.put(new UriPattern("http://*/config/v1/*/"), foo1);
handlers.put(new UriPattern("http://*/config/v1/*/*"), foo2);
handlers.put(new UriPattern("http://*/config/v1/*/*/"), foo3);
handlers.put(new UriPattern("http://*/application/v2/tenant/"), foo4);
handlers.put(new UriPattern("http://*/application/v2/tenant/*"), foo5);
handlers.put(new UriPattern("http://*/application/v2/tenant/*/session"), foo6);
handlers.put(new UriPattern("http://*/application/v2/tenant/*/session/*/prepared"), foo7);
handlers.put(new UriPattern("http://*/application/v2/tenant/*/session/*/active"), foo8);
handlers.put(new UriPattern("http://*/application/v2/tenant/*/session/*/content/*"), foo9);
handlers.put(new UriPattern("http://*/application/v2/tenant/*/application/"), foo10);
handlers.put(new UriPattern("http://*/application/v2/tenant/*/application/*/environment/*/" + "region/*/instance/*/content/*"), foo11);
handlers.put(new UriPattern("http://*/config/v2/tenant/*/application/*/*"), foo12);
handlers.put(new UriPattern("http://*/config/v2/tenant/*/application/*/*/*"), foo13);
handlers.put(new UriPattern("http://*/config/v2/tenant/*/application/*/environment" + "/*/region/*/instance/*/*"), foo14);
handlers.put(new UriPattern("http://*/config/v2/tenant/*/application/*/*/*/"), foo15);
BindingSet<RequestHandler> bindings = new BindingSet<>(handlers.entrySet());
assertNotNull(bindings);
assertSame(foo, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v1/cloud.config.log.logd")));
assertSame(foo1, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v1/cloud.config.log.logd/")));
assertSame(foo2, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v1/cloud.config.log.logd/admin")));
assertSame(foo3, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v1/cloud.config.log.logd/admin/")));
assertSame(foo4, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/")));
assertSame(foo5, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/b")));
assertSame(foo6, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/bar/session")));
assertSame(foo7, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/bar/session/aef/prepared")));
assertSame(foo8, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/bar/session/a/active")));
assertSame(foo9, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/bar/session/aef/content/x")));
assertSame(foo10, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/bar/session/application/")));
assertSame(foo11, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/application/v2/tenant/bar/application/bbc/environment/xyz/region/m/inst" + "ance/a/content/l")));
assertSame(foo12, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v2/tenant/bar/application/bbc/xyz")));
assertSame(foo13, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v2/tenant/bar/application/bbc/xyz/a")));
assertSame(foo14, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v2/tenant/bar/application/bbc/environment/a/region/b/instance/a/b")));
assertSame(foo15, bindings.resolve(URI.create("http://abcxyz.yahoo.com:19071" + "/config/v2/tenant/bar/application/bbc/xyz/a/c/")));
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class BindingSetTestCase method requireThatSchemeOrderOverHost.
@Test
public void requireThatSchemeOrderOverHost() {
Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler bar = new NonWorkingRequestHandler();
handlers.put(new UriPattern("http://host:5050/a/"), foo);
handlers.put(new UriPattern("ftp://host:5050/a/"), bar);
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("ftp://host:5050/a/")));
}
use of com.yahoo.jdisc.test.NonWorkingRequestHandler in project vespa by vespa-engine.
the class ActiveContainerTestCase method requireThatServerBindingAccessorWorks.
@Test
public void requireThatServerBindingAccessorWorks() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler bar = new NonWorkingRequestHandler();
builder.serverBindings().bind("http://host/foo", foo);
builder.serverBindings("bar").bind("http://host/bar", bar);
ActiveContainer container = new ActiveContainer(builder);
Map<String, BindingSet<RequestHandler>> bindings = container.serverBindings();
assertNotNull(bindings);
assertEquals(2, bindings.size());
BindingSet<RequestHandler> set = bindings.get(BindingSet.DEFAULT);
assertNotNull(set);
Iterator<Map.Entry<UriPattern, RequestHandler>> it = set.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());
assertFalse(it.hasNext());
assertNotNull(set = bindings.get("bar"));
assertNotNull(it = set.iterator());
assertTrue(it.hasNext());
assertNotNull(entry = it.next());
assertEquals(new UriPattern("http://host/bar"), entry.getKey());
assertSame(bar, entry.getValue());
assertFalse(it.hasNext());
assertNotNull(bindings = container.clientBindings());
assertEquals(1, bindings.size());
assertNotNull(set = bindings.get(BindingSet.DEFAULT));
assertNotNull(it = set.iterator());
assertFalse(it.hasNext());
driver.close();
}
Aggregations