Search in sources :

Example 11 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class AbstractApplicationTestCase method requireThatContainerApiIsAvailable.

@Test
public void requireThatContainerApiIsAvailable() {
    TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class);
    MyApplication app = (MyApplication) driver.application();
    app.activateContainer(app.newContainerBuilder());
    assertNotNull(app.container());
    assertTrue(driver.close());
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 12 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class ContainerBuilderTestCase method requireThatBindingSetsAreCreatedOnDemand.

@Test
public void requireThatBindingSetsAreCreatedOnDemand() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    BindingRepository<?> repo = builder.serverBindings("foo");
    assertNotNull(repo);
    assertSame(repo, builder.serverBindings("foo"));
    assertNotNull(repo = builder.serverBindings("bar"));
    assertSame(repo, builder.serverBindings("bar"));
    assertNotNull(repo = builder.clientBindings("baz"));
    assertSame(repo, builder.clientBindings("baz"));
    assertNotNull(repo = builder.clientBindings("cox"));
    assertSame(repo, builder.clientBindings("cox"));
    driver.close();
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 13 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class ContainerBuilderTestCase method requireThatContainerThreadFactoryIsBound.

@Test
public void requireThatContainerThreadFactoryIsBound() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    assertSame(ContainerThread.Factory.class, builder.getInstance(ThreadFactory.class).getClass());
    assertTrue(driver.close());
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 14 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class MbusRequestHandlerTestCase method requireThatHandlerCanRespondInSameThread.

@Test
public void requireThatHandlerCanRespondInSameThread() throws Exception {
    TestDriver driver = newTestDriver(SameThreadReplier.INSTANCE);
    Response response = dispatchMessage(driver, new SimpleMessage("msg")).get(60, TimeUnit.SECONDS);
    assertTrue(response instanceof MbusResponse);
    assertEquals(Response.Status.OK, response.getStatus());
    Reply reply = ((MbusResponse) response).getReply();
    assertTrue(reply instanceof EmptyReply);
    assertFalse(reply.hasErrors());
    assertTrue(driver.close());
}
Also used : Response(com.yahoo.jdisc.Response) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) TestDriver(com.yahoo.jdisc.test.TestDriver) EmptyReply(com.yahoo.messagebus.EmptyReply) Test(org.junit.Test)

Example 15 with TestDriver

use of com.yahoo.jdisc.test.TestDriver 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)

Aggregations

TestDriver (com.yahoo.jdisc.test.TestDriver)134 Test (org.junit.Test)128 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)39 Request (com.yahoo.jdisc.Request)22 Bundle (org.osgi.framework.Bundle)14 AbstractModule (com.google.inject.AbstractModule)13 ByteBuffer (java.nio.ByteBuffer)12 Response (com.yahoo.jdisc.Response)10 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)10 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)6 Executor (java.util.concurrent.Executor)6 LinkedList (java.util.LinkedList)5 BundleContext (org.osgi.framework.BundleContext)4 BindingSet (com.yahoo.jdisc.application.BindingSet)3 ServerProvider (com.yahoo.jdisc.service.ServerProvider)3 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)3 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 BundleException (org.osgi.framework.BundleException)3 Module (com.google.inject.Module)2