Search in sources :

Example 6 with ContainerBuilder

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

the class MockUserDatabaseClientTest method setupJDisc.

private void setupJDisc(Collection<Chain<Processor>> chains) {
    driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    ChainRegistry<Processor> registry = new ChainRegistry<>();
    for (Chain<Processor> chain : chains) registry.register(chain.getId(), chain);
    builder.clientBindings().bind("pio://endpoint/*", new MockUserDatabaseRequestHandler());
    driver.activateContainer(builder);
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) Processor(com.yahoo.processing.Processor) ChainRegistry(com.yahoo.processing.execution.chain.ChainRegistry)

Example 7 with ContainerBuilder

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

the class MbusRequestHandlerTestCase method newTestDriver.

private static TestDriver newTestDriver(MbusRequestHandler handler) {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverBindings().bind("mbus://*/*", handler);
    driver.activateContainer(builder);
    return driver;
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) TestDriver(com.yahoo.jdisc.test.TestDriver)

Example 8 with ContainerBuilder

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

the class ContainerTerminationTestCase method requireThatAppContextIsFromBuilder.

@Test
public void requireThatAppContextIsFromBuilder() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    Object obj = new Object();
    builder.setAppContext(obj);
    driver.activateContainer(builder);
    DeactivatedContainer container = driver.activateContainer(null);
    assertSame(obj, container.appContext());
    assertTrue(driver.close());
}
Also used : DeactivatedContainer(com.yahoo.jdisc.application.DeactivatedContainer) ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 9 with ContainerBuilder

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

the class ServerProviderConformanceTest method runTest.

private <T extends ServerProvider, U, V> void runTest(final Adapter<T, U, V> adapter, final Module testConfig, final RequestType requestType, final TestRequestHandler requestHandler) throws Throwable {
    final Module config = Modules.override(newDefaultConfig(), adapter.newConfigModule()).with(testConfig);
    final TestDriver driver = TestDriver.newSimpleApplicationInstance(config);
    final ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverBindings().bind(builder.getInstance(Key.get(String.class, Names.named("serverBinding"))), requestHandler);
    final T serverProvider = builder.guiceModules().getInstance(adapter.getServerProviderClass());
    builder.serverProviders().install(serverProvider);
    if (builder.getInstance(Key.get(Boolean.class, Names.named("activateContainer")))) {
        driver.activateContainer(builder);
    }
    serverProvider.start();
    serverProvider.release();
    for (int i = 0; i < NUM_RUNS_EACH_TEST; ++i) {
        log.fine("Test run #" + i);
        requestHandler.reset(adapter.newResponseContent());
        final U client = adapter.newClient(serverProvider);
        final boolean withRequestContent = requestType == RequestType.WITH_CONTENT;
        final V result = adapter.executeRequest(client, withRequestContent);
        adapter.validateResponse(result);
        if (client instanceof Closeable) {
            ((Closeable) client).close();
        }
        requestHandler.awaitAsyncTasks();
    }
    serverProvider.close();
    driver.close();
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) Closeable(java.io.Closeable) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule)

Example 10 with ContainerBuilder

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

the class LatencyTestCase method runLatencyMeasurements.

@Test
public void runLatencyMeasurements() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    MyRequestHandler foo = new MyRequestHandler("foo");
    MyRequestHandler bar = new MyRequestHandler("bar");
    MyRequestHandler baz = new MyRequestHandler("baz");
    builder.serverBindings().bind(foo.uri, foo);
    builder.serverBindings().bind(bar.uri, bar);
    builder.serverBindings().bind(baz.uri, baz);
    driver.activateContainer(builder);
    measureLatencies(NUM_REQUESTS, driver, foo, bar, baz);
    TimeTrack time = measureLatencies(NUM_REQUESTS, driver, foo, bar, baz);
    System.err.println("\n" + time);
    foo.release();
    bar.release();
    baz.release();
    assertTrue(driver.close());
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

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