use of com.yahoo.jdisc.Response in project vespa by vespa-engine.
the class FutureResponseTestCase method requireThatCompletionIsDoneWhenHandlerIsCalled.
@Test
public void requireThatCompletionIsDoneWhenHandlerIsCalled() {
FutureResponse future = new FutureResponse();
assertFalse(future.isDone());
future.handleResponse(new Response(69));
assertTrue(future.isDone());
}
use of com.yahoo.jdisc.Response in project vespa by vespa-engine.
the class FutureResponseTestCase method requireThatResponseContentIsReturnedToCaller.
@Test
public void requireThatResponseContentIsReturnedToCaller() throws Exception {
ContentChannel content = new NonWorkingContentChannel();
FutureResponse future = new FutureResponse(content);
Response response = new Response(Response.Status.OK);
assertSame(content, future.handleResponse(response));
}
use of com.yahoo.jdisc.Response in project vespa by vespa-engine.
the class FutureResponseTestCase method requireThatResponseBecomesAvailable.
@Test
public void requireThatResponseBecomesAvailable() throws Exception {
FutureResponse future = new FutureResponse();
try {
future.get(0, TimeUnit.MILLISECONDS);
fail();
} catch (TimeoutException e) {
}
Response response = new Response(Response.Status.OK);
future.handleResponse(response);
assertSame(response, future.get(0, TimeUnit.MILLISECONDS));
}
use of com.yahoo.jdisc.Response in project vespa by vespa-engine.
the class RequestDispatchTestCase method requireThatStreamCanBeConnected.
@Test
public void requireThatStreamCanBeConnected() throws IOException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
ReadableContentChannel content = new ReadableContentChannel();
MyRequestHandler requestHandler = new MyRequestHandler(content, new Response(Response.Status.OK));
builder.serverBindings().bind("http://localhost/", requestHandler);
driver.activateContainer(builder);
OutputStream out = new FastContentOutputStream(driver.newRequestDispatch("http://localhost/", new FutureResponse()).connect());
out.write(6);
out.write(9);
out.close();
InputStream in = content.toStream();
assertEquals(6, in.read());
assertEquals(9, in.read());
assertEquals(-1, in.read());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.Response in project vespa by vespa-engine.
the class NonWorkingResponseHandlerTestCase method requireThatHandleResponseThrowsException.
@Test
public void requireThatHandleResponseThrowsException() {
NonWorkingResponseHandler handler = new NonWorkingResponseHandler();
try {
handler.handleResponse(new Response(Response.Status.OK));
fail();
} catch (UnsupportedOperationException e) {
}
}
Aggregations