Search in sources :

Example 6 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class ContainerShutdownTestCase method requireThatNullRequestContentWithEagerCloseResponseBlocksTermination.

@Test
public void requireThatNullRequestContentWithEagerCloseResponseBlocksTermination() {
    MyRequestHandler requestHandler = MyRequestHandler.newNulContentWithEagerCloseResponse();
    Context ctx = Context.newPendingRequest(requestHandler);
    ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion());
    ctx.request.release();
    assertFalse(ctx.shutdown());
    requestContent.close(null);
    assertTrue(ctx.terminated);
    assertTrue(ctx.driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Example 7 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class ContainerShutdownTestCase method requireThatOpenResponseBlocksTermination.

@Test
public void requireThatOpenResponseBlocksTermination() {
    MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion();
    Context ctx = Context.newPendingRequest(requestHandler);
    ctx.request.connect(MyResponseHandler.newEagerCompletion()).close(null);
    ctx.request.release();
    ContentChannel responseContent = requestHandler.respond();
    assertFalse(ctx.shutdown());
    responseContent.close(null);
    assertTrue(ctx.terminated);
    assertTrue(ctx.driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Example 8 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class ContainerShutdownTestCase method requireThatOpenRequestBlocksTermination.

@Test
public void requireThatOpenRequestBlocksTermination() {
    MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion();
    Context ctx = Context.newPendingRequest(requestHandler);
    ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion());
    ctx.request.release();
    requestHandler.respond().close(null);
    assertFalse(ctx.shutdown());
    requestContent.close(null);
    assertTrue(ctx.terminated);
    assertTrue(ctx.driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Example 9 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class ContainerShutdownTestCase method requireThatRequestCloseCompletionBlocksTermination.

@Test
public void requireThatRequestCloseCompletionBlocksTermination() {
    MyRequestHandler requestHandler = MyRequestHandler.newEagerCloseResponse();
    Context ctx = Context.newPendingRequest(requestHandler);
    ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion());
    ctx.request.release();
    requestContent.close(MyCompletion.newInstance());
    assertFalse(ctx.shutdown());
    requestHandler.requestContent.closeCompletion.completed();
    assertTrue(ctx.terminated);
    assertTrue(ctx.driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Example 10 with ContentChannel

use of com.yahoo.jdisc.handler.ContentChannel in project vespa by vespa-engine.

the class ContainerShutdownTestCase method requireThatRequestContentWriteExceptionDoesNotForceTermination.

@Test
public void requireThatRequestContentWriteExceptionDoesNotForceTermination() {
    MyRequestHandler requestHandler = MyRequestHandler.newContentWriteExceptionWithEagerCompletion();
    Context ctx = Context.newPendingRequest(requestHandler);
    ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion());
    try {
        requestContent.write(ByteBuffer.allocate(69), null);
        fail();
    } catch (MyException e) {
    // ignore
    }
    ctx.request.release();
    requestHandler.respond().close(null);
    assertFalse(ctx.shutdown());
    requestContent.close(null);
    assertTrue(ctx.terminated);
    assertTrue(ctx.driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Aggregations

ContentChannel (com.yahoo.jdisc.handler.ContentChannel)48 Test (org.junit.Test)31 Request (com.yahoo.jdisc.Request)10 Response (com.yahoo.jdisc.Response)10 TestDriver (com.yahoo.jdisc.test.TestDriver)10 ByteBuffer (java.nio.ByteBuffer)7 ResponseHandler (com.yahoo.jdisc.handler.ResponseHandler)6 HttpRequest (com.yahoo.jdisc.http.HttpRequest)4 ResourceReference (com.yahoo.jdisc.ResourceReference)3 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)3 Callable (java.util.concurrent.Callable)3 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)2 BindingNotFoundException (com.yahoo.jdisc.handler.BindingNotFoundException)2 RequestDeniedException (com.yahoo.jdisc.handler.RequestDeniedException)2 NonWorkingRequest (com.yahoo.jdisc.test.NonWorkingRequest)2 AbstractRequestHandler (com.yahoo.jdisc.handler.AbstractRequestHandler)1 BufferedContentChannel (com.yahoo.jdisc.handler.BufferedContentChannel)1 ReadableContentChannel (com.yahoo.jdisc.handler.ReadableContentChannel)1 RequestDispatch (com.yahoo.jdisc.handler.RequestDispatch)1 HttpResponse (com.yahoo.jdisc.http.HttpResponse)1