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;
}
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();
}
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());
}
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());
}
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());
}
Aggregations