use of org.jboss.netty.handler.codec.http.DefaultHttpChunk in project databus by linkedin.
the class TestResponseProcessors method testStreamHappyPathChunked.
@Test
public void testStreamHappyPathChunked() throws Exception {
TestAbstractQueue queue = new TestAbstractQueue();
TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
StreamHttpResponseProcessor processor = new StreamHttpResponseProcessor(null, queue, stateMsg, null);
ChannelBuffer buf = HeapChannelBufferFactory.getInstance().getBuffer(100);
HttpChunk httpChunk = new DefaultHttpChunk(buf);
HttpChunkTrailer httpChunkTrailer = new DefaultHttpChunkTrailer();
processor.startResponse(httpResponse);
processor.addChunk(httpChunk);
processor.addTrailer(httpChunkTrailer);
processor.finishResponse();
Assert.assertEquals("Error Handled", false, processor._errorHandled);
Assert.assertEquals("Processor Response State", AbstractHttpResponseProcessorDecorator.ResponseStatus.CHUNKS_FINISHED, processor._responseStatus);
Assert.assertEquals("Actor Queue Size", 1, queue.getMessages().size());
Assert.assertEquals("Expected ConnectionStateMessage", "TestConnectionStateMessage", queue.getMessages().get(0).getClass().getSimpleName());
TestConnectionStateMessage gotMsg = (TestConnectionStateMessage) (queue.getMessages().get(0));
Assert.assertEquals("Expected ConnectionStateMessage State", TestConnectionStateMessage.State.STREAM_RESPONSE_SUCCESS, gotMsg._state);
Assert.assertEquals("No More CHunks", true, stateMsg._channel.hasNoMoreChunks());
}
use of org.jboss.netty.handler.codec.http.DefaultHttpChunk in project databus by linkedin.
the class TestResponseProcessors method testRegisterExceptionAfterStartCase2.
@Test
public void testRegisterExceptionAfterStartCase2() throws Exception {
TestAbstractQueue queue = new TestAbstractQueue();
TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
RegisterHttpResponseProcessor processor = new RegisterHttpResponseProcessor(null, queue, stateMsg, null);
ChannelBuffer buf = getRegisterResponse();
HttpChunk httpChunk = new DefaultHttpChunk(buf);
HttpChunkTrailer httpChunkTrailer = new DefaultHttpChunkTrailer();
processor.startResponse(httpResponse);
processor.addChunk(httpChunk);
processor.channelException(new Exception("dummy exception"));
processor.addTrailer(httpChunkTrailer);
processor.finishResponse();
Assert.assertEquals("Error Handled", true, processor._errorHandled);
Assert.assertEquals("Processor Response State", AbstractHttpResponseProcessorDecorator.ResponseStatus.CHUNKS_FINISHED, processor._responseStatus);
Assert.assertEquals("Actor Queue Size", 1, queue.getMessages().size());
Assert.assertEquals("Expected ConnectionStateMessage", "TestConnectionStateMessage", queue.getMessages().get(0).getClass().getSimpleName());
TestConnectionStateMessage gotMsg = (TestConnectionStateMessage) (queue.getMessages().get(0));
Assert.assertEquals("Expected ConnectionStateMessage State", TestConnectionStateMessage.State.REGISTER_RESPONSE_ERROR, gotMsg._state);
Assert.assertEquals("No More CHunks", true, (null == stateMsg._registerResponse));
}
use of org.jboss.netty.handler.codec.http.DefaultHttpChunk in project databus by linkedin.
the class TestResponseProcessors method testRegisterExceptionAfterStartCase1.
@Test
public void testRegisterExceptionAfterStartCase1() throws Exception {
TestAbstractQueue queue = new TestAbstractQueue();
TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
RegisterHttpResponseProcessor processor = new RegisterHttpResponseProcessor(null, queue, stateMsg, null);
ChannelBuffer buf = getRegisterResponse();
HttpChunk httpChunk = new DefaultHttpChunk(buf);
HttpChunkTrailer httpChunkTrailer = new DefaultHttpChunkTrailer();
processor.startResponse(httpResponse);
processor.channelException(new Exception("dummy exception"));
processor.addChunk(httpChunk);
processor.addTrailer(httpChunkTrailer);
processor.finishResponse();
Assert.assertEquals("Error Handled", true, processor._errorHandled);
Assert.assertEquals("Processor Response State", AbstractHttpResponseProcessorDecorator.ResponseStatus.CHUNKS_FINISHED, processor._responseStatus);
Assert.assertEquals("Actor Queue Size", 1, queue.getMessages().size());
Assert.assertEquals("Expected ConnectionStateMessage", "TestConnectionStateMessage", queue.getMessages().get(0).getClass().getSimpleName());
TestConnectionStateMessage gotMsg = (TestConnectionStateMessage) (queue.getMessages().get(0));
Assert.assertEquals("Expected ConnectionStateMessage State", TestConnectionStateMessage.State.REGISTER_RESPONSE_ERROR, gotMsg._state);
Assert.assertEquals("No More CHunks", true, (null == stateMsg._registerResponse));
}
use of org.jboss.netty.handler.codec.http.DefaultHttpChunk in project databus by linkedin.
the class TestResponseProcessors method testStartSCNBootstrapTooOldException.
@Test
public void testStartSCNBootstrapTooOldException() throws Exception {
TestAbstractQueue queue = new TestAbstractQueue();
TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
DefaultHttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
remoteExHandler._exType = ExceptionType.BOOTSTRAP_TOO_OLD_EXCEPTION;
Checkpoint cp = new Checkpoint();
cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
BootstrapStartScnHttpResponseProcessor processor = new BootstrapStartScnHttpResponseProcessor(null, queue, stateMsg, cp, remoteExHandler, null);
ChannelBuffer buf = getScnResponse();
HttpChunk httpChunk = new DefaultHttpChunk(buf);
HttpChunkTrailer httpChunkTrailer = new DefaultHttpChunkTrailer();
processor.startResponse(httpResponse);
processor.addChunk(httpChunk);
processor.addTrailer(httpChunkTrailer);
processor.finishResponse();
Assert.assertEquals("Error Handled", false, processor._errorHandled);
Assert.assertEquals("Processor Response State", AbstractHttpResponseProcessorDecorator.ResponseStatus.CHUNKS_FINISHED, processor._responseStatus);
Assert.assertEquals("Actor Queue Size", 1, queue.getMessages().size());
Assert.assertEquals("Expected ConnectionStateMessage", "TestConnectionStateMessage", queue.getMessages().get(0).getClass().getSimpleName());
TestConnectionStateMessage gotMsg = (TestConnectionStateMessage) (queue.getMessages().get(0));
Assert.assertEquals("Expected ConnectionStateMessage State", TestConnectionStateMessage.State.STARTSCN_RESPONSE_ERROR, gotMsg._state);
Assert.assertEquals("No response", true, (null == stateMsg._cp));
}
use of org.jboss.netty.handler.codec.http.DefaultHttpChunk in project databus by linkedin.
the class TestResponseProcessors method testStreamExceptionAfterStartCase2.
@Test
public void testStreamExceptionAfterStartCase2() throws Exception {
TestAbstractQueue queue = new TestAbstractQueue();
TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
StreamHttpResponseProcessor processor = new StreamHttpResponseProcessor(null, queue, stateMsg, null);
ChannelBuffer buf = HeapChannelBufferFactory.getInstance().getBuffer(100);
HttpChunk httpChunk = new DefaultHttpChunk(buf);
HttpChunkTrailer httpChunkTrailer = new DefaultHttpChunkTrailer();
processor.startResponse(httpResponse);
processor.addChunk(httpChunk);
processor.channelException(new Exception("dummy exception"));
processor.addTrailer(httpChunkTrailer);
processor.finishResponse();
Assert.assertEquals("Error Handled", true, processor._errorHandled);
Assert.assertEquals("Processor Response State", AbstractHttpResponseProcessorDecorator.ResponseStatus.CHUNKS_FINISHED, processor._responseStatus);
Assert.assertEquals("Actor Queue Size", 1, queue.getMessages().size());
Assert.assertEquals("Expected ConnectionStateMessage", "TestConnectionStateMessage", queue.getMessages().get(0).getClass().getSimpleName());
TestConnectionStateMessage gotMsg = (TestConnectionStateMessage) (queue.getMessages().get(0));
Assert.assertEquals("Expected ConnectionStateMessage State", TestConnectionStateMessage.State.STREAM_RESPONSE_SUCCESS, gotMsg._state);
Assert.assertEquals("No More CHunks", true, stateMsg._channel.hasNoMoreChunks());
}
Aggregations