Search in sources :

Example 16 with TestDriver

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

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

the class AbstractServerProviderTestCase method requireThatAbstractClassIsAServerProvider.

@Test
public void requireThatAbstractClassIsAServerProvider() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    assertTrue(ServerProvider.class.isInstance(new MyServerProvider(driver)));
    assertTrue(driver.close());
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 18 with TestDriver

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

the class CurrentContainerTestCase method requireThatNewRequestsCreateSnapshot.

@Test
public void requireThatNewRequestsCreateSnapshot() throws Exception {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    driver.activateContainer(driver.newContainerBuilder());
    Request request = new Request(driver, URI.create("http://host/path"));
    assertNotNull(request.container());
    request.release();
    driver.close();
}
Also used : Request(com.yahoo.jdisc.Request) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 19 with TestDriver

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

the class ProxyRequestHandlerTestCase method requireThatRequestContentCompletedIsProxied.

@Test
public void requireThatRequestContentCompletedIsProxied() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    MyRequestHandler requestHandler = MyRequestHandler.newInstance();
    Request request = newRequest(driver, requestHandler);
    ContentChannel resolvedContent = request.connect(MyResponseHandler.newEagerCompletion());
    request.release();
    assertSame(request, requestHandler.request);
    ByteBuffer buf = ByteBuffer.allocate(69);
    resolvedContent.write(buf, null);
    assertSame(buf, requestHandler.content.writeBuf);
    requestHandler.content.writeCompletion.completed();
    MyCompletion writeCompletion = new MyCompletion();
    resolvedContent.write(buf = ByteBuffer.allocate(69), writeCompletion);
    assertSame(buf, requestHandler.content.writeBuf);
    assertFalse(writeCompletion.completed);
    assertNull(writeCompletion.failed);
    requestHandler.content.writeCompletion.completed();
    assertTrue(writeCompletion.completed);
    assertNull(writeCompletion.failed);
    MyCompletion closeCompletion = new MyCompletion();
    resolvedContent.close(closeCompletion);
    assertTrue(requestHandler.content.closed);
    assertFalse(closeCompletion.completed);
    assertNull(writeCompletion.failed);
    requestHandler.content.closeCompletion.completed();
    assertTrue(closeCompletion.completed);
    assertNull(closeCompletion.failed);
    requestHandler.respond();
    assertTrue(driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) ByteBuffer(java.nio.ByteBuffer) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 20 with TestDriver

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

the class ProxyRequestHandlerTestCase method requireThatNullRequestContentIsProxied.

@Test
public void requireThatNullRequestContentIsProxied() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    MyRequestHandler requestHandler = MyRequestHandler.newNullContent();
    Request request = newRequest(driver, requestHandler);
    request.connect(MyResponseHandler.newEagerCompletion()).close(null);
    request.release();
    requestHandler.respond();
    assertTrue(driver.close());
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

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