Search in sources :

Example 46 with TestDriver

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

the class DiscFilterRequestTest method newRequest.

private static HttpRequest newRequest(URI uri, HttpRequest.Method method, HttpRequest.Version version) {
    InetSocketAddress address = new InetSocketAddress("example.yahoo.com", 69);
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    driver.activateContainer(driver.newContainerBuilder());
    HttpRequest request = HttpRequest.newServerRequest(driver, uri, method, version, address);
    request.release();
    assertTrue(driver.close());
    return request;
}
Also used : HttpRequest(com.yahoo.jdisc.http.HttpRequest) InetSocketAddress(java.net.InetSocketAddress) TestDriver(com.yahoo.jdisc.test.TestDriver)

Example 47 with TestDriver

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

the class MbusRequestTestCase method requireThatAccessorsWork.

@Test
public void requireThatAccessorsWork() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    driver.activateContainer(driver.newContainerBuilder());
    MyMessage msg = new MyMessage();
    MbusRequest request = new MbusRequest(driver, URI.create("mbus://host/path"), msg);
    assertSame(msg, request.getMessage());
    request.release();
    driver.close();
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 48 with TestDriver

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

the class MbusRequestTestCase method requireThatMessageCanNotBeNullInRootRequest.

@Test
public void requireThatMessageCanNotBeNullInRootRequest() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    driver.activateContainer(driver.newContainerBuilder());
    try {
        new MbusRequest(driver, URI.create("mbus://host/path"), null);
        fail();
    } catch (NullPointerException e) {
    // expected
    }
    assertTrue(driver.close());
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 49 with TestDriver

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

the class MbusRequestTestCase method requireThatMessageCanNotBeNullInChildRequest.

@Test
public void requireThatMessageCanNotBeNullInChildRequest() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    driver.activateContainer(driver.newContainerBuilder());
    MbusRequest parent = new MbusRequest(driver, URI.create("mbus://host/path"), new SimpleMessage("foo"));
    try {
        new MbusRequest(parent, URI.create("mbus://host/path"), null);
        fail();
    } catch (NullPointerException e) {
    // expected
    }
    parent.release();
    assertTrue(driver.close());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 50 with TestDriver

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

the class AbstractRequestHandlerTestCase method requireThatForwardWorks.

@Test
public void requireThatForwardWorks() throws InterruptedException {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverBindings().bind("http://localhost/", new ForwardHandler());
    builder.clientBindings().bind("http://remotehost/", new EchoHandler());
    driver.activateContainer(builder);
    for (int i = 0; i < NUM_REQUESTS; ++i) {
        MyResponseHandler responseHandler = new MyResponseHandler();
        RequestDispatch dispatch = driver.newRequestDispatch("http://localhost/", responseHandler);
        FastContentWriter requestContent = dispatch.connectFastWriter();
        ByteBuffer buf = ByteBuffer.allocate(69);
        requestContent.write(buf);
        requestContent.close();
        assertSame(buf, responseHandler.content.read());
        assertNull(responseHandler.content.read());
    }
    assertTrue(driver.close());
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) ByteBuffer(java.nio.ByteBuffer) 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