Search in sources :

Example 6 with RequestHandler

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);
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 7 with RequestHandler

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")));
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 8 with RequestHandler

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());
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 9 with RequestHandler

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);
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 10 with RequestHandler

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/")));
}
Also used : RequestHandler(com.yahoo.jdisc.handler.RequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Aggregations

RequestHandler (com.yahoo.jdisc.handler.RequestHandler)43 Test (org.junit.Test)33 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)23 LinkedHashMap (java.util.LinkedHashMap)19 TestDriver (com.yahoo.jdisc.test.TestDriver)6 Map (java.util.Map)6 AbstractRequestHandler (com.yahoo.jdisc.handler.AbstractRequestHandler)5 ComponentId (com.yahoo.component.ComponentId)4 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)4 BindingSet (com.yahoo.jdisc.application.BindingSet)3 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)3 Container (com.yahoo.container.Container)2 RequestHandlerTestDriver (com.yahoo.container.jdisc.RequestHandlerTestDriver)2 ThreadedHttpRequestHandler (com.yahoo.container.jdisc.ThreadedHttpRequestHandler)2 DocumentProcessingHandler (com.yahoo.docproc.jdisc.DocumentProcessingHandler)2 Request (com.yahoo.jdisc.Request)2 UriPattern (com.yahoo.jdisc.application.UriPattern)2 BindingNotFoundException (com.yahoo.jdisc.handler.BindingNotFoundException)2 RequestDeniedException (com.yahoo.jdisc.handler.RequestDeniedException)2 JSONArray (org.json.JSONArray)2