Search in sources :

Example 36 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler 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());
}
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 37 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler 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/")));
}
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 38 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler 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/")));
}
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 39 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler 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/")));
}
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 40 with RequestHandler

use of com.yahoo.jdisc.handler.RequestHandler in project vespa by vespa-engine.

the class BindingSetTestCase method requireThatTreeSplitCanBeBoundForSchemes.

@Test
public void requireThatTreeSplitCanBeBoundForSchemes() {
    Map<UriPattern, RequestHandler> handlers = new LinkedHashMap<>();
    RequestHandler httpfoo = new NonWorkingRequestHandler();
    RequestHandler httpsfoo = new NonWorkingRequestHandler();
    RequestHandler ftpfoo = new NonWorkingRequestHandler();
    handlers.put(new UriPattern("http://host/foo"), httpfoo);
    handlers.put(new UriPattern("https://host/foo"), httpsfoo);
    handlers.put(new UriPattern("ftp://host/foo"), ftpfoo);
    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)

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