Search in sources :

Example 41 with ContentChannel

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

the class ContainerShutdownTestCase method requireThatRequestContentCloseFailedDoesNotBlockTermination.

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

Example 42 with ContentChannel

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

the class ContainerShutdownTestCase method requireThatRequestWriteCompletionExceptionDoesNotBlockTermination.

@Test
public void requireThatRequestWriteCompletionExceptionDoesNotBlockTermination() {
    MyRequestHandler requestHandler = MyRequestHandler.newEagerCloseResponse();
    Context ctx = Context.newPendingRequest(requestHandler);
    ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion());
    ctx.request.release();
    requestContent.write(null, MyCompletion.newException());
    requestContent.close(null);
    requestHandler.requestContent.closeCompletion.completed();
    assertFalse(ctx.shutdown());
    try {
        requestHandler.requestContent.writeCompletion.completed();
        fail();
    } catch (MyException e) {
    // ignore
    }
    assertTrue(ctx.terminated);
    assertTrue(ctx.driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Example 43 with ContentChannel

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

the class ContainerShutdownTestCase method requireThatRequestContentWriteFailedDoesNotBlockTermination.

@Test
public void requireThatRequestContentWriteFailedDoesNotBlockTermination() {
    MyRequestHandler requestHandler = MyRequestHandler.newEagerFail();
    Context ctx = Context.newPendingRequest(requestHandler);
    ContentChannel requestContent = ctx.request.connect(MyResponseHandler.newEagerCompletion());
    requestContent.write(ByteBuffer.allocate(69), null);
    requestContent.close(null);
    ctx.request.release();
    requestHandler.respond().close(null);
    assertTrue(ctx.shutdown());
    assertTrue(ctx.driver.close());
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Example 44 with ContentChannel

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

the class NonWorkingContentChannelTestCase method requireThatWriteThrowsException.

@Test
public void requireThatWriteThrowsException() {
    ContentChannel content = new NonWorkingContentChannel();
    try {
        content.write(null, null);
        fail();
    } catch (UnsupportedOperationException e) {
    }
    content = new NonWorkingContentChannel();
    try {
        content.write(ByteBuffer.allocate(69), null);
        fail();
    } catch (UnsupportedOperationException e) {
    }
    content = new NonWorkingContentChannel();
    try {
        content.write(ByteBuffer.allocate(69), new MyCompletion());
        fail();
    } catch (UnsupportedOperationException e) {
    }
    content = new NonWorkingContentChannel();
    try {
        content.write(null, new MyCompletion());
        fail();
    } catch (UnsupportedOperationException e) {
    }
}
Also used : ContentChannel(com.yahoo.jdisc.handler.ContentChannel) Test(org.junit.Test)

Example 45 with ContentChannel

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

the class MbusClientTestCase method requireThatRequestContentDoesNotSupportWrite.

@Test
public void requireThatRequestContentDoesNotSupportWrite() throws InterruptedException {
    ClientTestDriver driver = ClientTestDriver.newInstance();
    MyResponseHandler responseHandler = MyResponseHandler.newInstance();
    Request request = null;
    ContentChannel content;
    try {
        request = driver.newClientRequest(new SimpleMessage("foo"));
        content = request.connect(responseHandler);
    } finally {
        if (request != null) {
            request.release();
        }
    }
    try {
        content.write(ByteBuffer.allocate(69), null);
        fail();
    } catch (UnsupportedOperationException e) {
    }
    content.close(null);
    assertTrue(driver.awaitMessageAndSendReply(new EmptyReply()));
    assertNotNull(responseHandler.awaitResponse());
    assertTrue(driver.close());
}
Also used : ClientTestDriver(com.yahoo.messagebus.jdisc.test.ClientTestDriver) ContentChannel(com.yahoo.jdisc.handler.ContentChannel) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Request(com.yahoo.jdisc.Request) 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