Search in sources :

Example 16 with Response

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());
}
Also used : Response(com.yahoo.jdisc.Response) Test(org.junit.Test)

Example 17 with Response

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));
}
Also used : Response(com.yahoo.jdisc.Response) NonWorkingContentChannel(com.yahoo.jdisc.test.NonWorkingContentChannel) NonWorkingContentChannel(com.yahoo.jdisc.test.NonWorkingContentChannel) Test(org.junit.Test)

Example 18 with 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));
}
Also used : Response(com.yahoo.jdisc.Response) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 19 with Response

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());
}
Also used : Response(com.yahoo.jdisc.Response) ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 20 with Response

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) {
    }
}
Also used : Response(com.yahoo.jdisc.Response) Test(org.junit.Test)

Aggregations

Response (com.yahoo.jdisc.Response)52 Test (org.junit.Test)39 Request (com.yahoo.jdisc.Request)17 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)14 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)11 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)11 TestDriver (com.yahoo.jdisc.test.TestDriver)10 ClientTestDriver (com.yahoo.messagebus.jdisc.test.ClientTestDriver)7 ResponseHandler (com.yahoo.jdisc.handler.ResponseHandler)6 SimpleReply (com.yahoo.messagebus.test.SimpleReply)6 ByteBuffer (java.nio.ByteBuffer)6 ServerTestDriver (com.yahoo.messagebus.jdisc.test.ServerTestDriver)5 Chain (com.yahoo.component.chain.Chain)3 HttpRequest (com.yahoo.jdisc.http.HttpRequest)3 HttpResponse (com.yahoo.jdisc.http.HttpResponse)3 NonWorkingRequest (com.yahoo.jdisc.test.NonWorkingRequest)3 Reply (com.yahoo.messagebus.Reply)3 Processor (com.yahoo.processing.Processor)3 Callable (java.util.concurrent.Callable)3 Test (org.testng.annotations.Test)3