Search in sources :

Example 16 with ContainerBuilder

use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.

the class ContainerResourceTestCase method requireThatServerProvidersAreRetainedOnActivate.

@Test
public void requireThatServerProvidersAreRetainedOnActivate() {
    MyServerProvider foo = new MyServerProvider();
    MyServerProvider bar = new MyServerProvider();
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverProviders().install(foo);
    builder.serverProviders().install(bar);
    assertEquals(0, foo.retainCnt.get());
    assertEquals(0, bar.retainCnt.get());
    driver.activateContainer(builder);
    assertEquals(1, foo.retainCnt.get());
    assertEquals(1, bar.retainCnt.get());
    assertTrue(driver.close());
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 17 with ContainerBuilder

use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.

the class ContainerSnapshotTestCase method requireThatServerHandlerCanBeResolved.

@Test
public void requireThatServerHandlerCanBeResolved() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverBindings().bind("http://foo/*", MyRequestHandler.newInstance());
    driver.activateContainer(builder);
    Request request = new Request(driver, URI.create("http://foo/"));
    assertNotNull(request.container().resolveHandler(request));
    assertNotNull(request.getBindingMatch());
    request.release();
    request = new Request(driver, URI.create("http://foo/"));
    request.setServerRequest(false);
    assertNull(request.container().resolveHandler(request));
    assertNull(request.getBindingMatch());
    request.release();
    request = new Request(driver, URI.create("http://bar/"));
    assertNull(request.container().resolveHandler(request));
    assertNull(request.getBindingMatch());
    request.release();
    request = new Request(driver, URI.create("http://bar/"));
    request.setServerRequest(false);
    assertNull(request.container().resolveHandler(request));
    assertNull(request.getBindingMatch());
    request.release();
    assertTrue(driver.close());
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) Request(com.yahoo.jdisc.Request) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 18 with ContainerBuilder

use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.

the class ContainerSnapshotTestCase method requireThatClientBindingsAreUsed.

@Test
public void requireThatClientBindingsAreUsed() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.clientBindings().bind("http://host/path", MyRequestHandler.newInstance());
    driver.activateContainer(builder);
    Request request = new Request(driver, URI.create("http://host/path"));
    assertNull(request.container().resolveHandler(request));
    request.setServerRequest(false);
    assertNotNull(request.container().resolveHandler(request));
    request.release();
    assertTrue(driver.close());
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) Request(com.yahoo.jdisc.Request) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 19 with ContainerBuilder

use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.

the class ContainerSnapshotTestCase method requireThatBindingMatchIsSetByResolveHandler.

@Test
public void requireThatBindingMatchIsSetByResolveHandler() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverBindings().bind("http://*/*", MyRequestHandler.newInstance());
    driver.activateContainer(builder);
    Request request = new Request(driver, URI.create("http://localhost:69/status.html"));
    assertNotNull(request.container().resolveHandler(request));
    BindingMatch<RequestHandler> match = request.getBindingMatch();
    assertNotNull(match);
    assertEquals(3, match.groupCount());
    assertEquals("localhost", match.group(0));
    assertEquals("69", match.group(1));
    assertEquals("status.html", match.group(2));
    request.release();
    assertTrue(driver.close());
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) RequestHandler(com.yahoo.jdisc.handler.RequestHandler) Request(com.yahoo.jdisc.Request) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 20 with ContainerBuilder

use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.

the class ThroughputTestCase method runMeasurements.

private static List<Long> runMeasurements(TestDriver driver, RequestHandler handler) throws Exception {
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverBindings().bind(HANDLER_URI, handler);
    driver.activateContainer(builder);
    handler.release();
    List<Long> ret = new LinkedList<>();
    for (int i = MIN_THREADS; i <= MAX_THREADS; i *= 2) {
        ret.add(measureThroughput(driver, i));
    }
    return ret;
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) LinkedList(java.util.LinkedList)

Aggregations

ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)53 Test (org.junit.Test)41 TestDriver (com.yahoo.jdisc.test.TestDriver)40 Request (com.yahoo.jdisc.Request)16 Response (com.yahoo.jdisc.Response)12 ByteBuffer (java.nio.ByteBuffer)7 Executor (java.util.concurrent.Executor)6 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)4 AbstractModule (com.google.inject.AbstractModule)3 BindingSet (com.yahoo.jdisc.application.BindingSet)3 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)3 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)3 Container (com.yahoo.jdisc.Container)2 UriPattern (com.yahoo.jdisc.application.UriPattern)2 Map (java.util.Map)2 ThreadFactory (java.util.concurrent.ThreadFactory)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Module (com.google.inject.Module)1 Pair (com.yahoo.collections.Pair)1