Search in sources :

Example 16 with NonWorkingRequestHandler

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());
}
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 17 with NonWorkingRequestHandler

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());
}
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 18 with NonWorkingRequestHandler

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/")));
}
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 19 with NonWorkingRequestHandler

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/")));
}
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 20 with NonWorkingRequestHandler

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/")));
}
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

NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)23 Test (org.junit.Test)23 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)22 LinkedHashMap (java.util.LinkedHashMap)19 Map (java.util.Map)3 BindingSet (com.yahoo.jdisc.application.BindingSet)2 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)2 UriPattern (com.yahoo.jdisc.application.UriPattern)2 TestDriver (com.yahoo.jdisc.test.TestDriver)2 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)1 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)1