use of com.nike.riposte.server.channelpipeline.message.OutboundMessage in project riposte by Nike-Inc.
the class ResponseFilterHandlerTest method doChannelRead_does_nothing_and_returns_CONTINUE_if_msg_is_not_a_first_chunk.
@Test
public void doChannelRead_does_nothing_and_returns_CONTINUE_if_msg_is_not_a_first_chunk() throws Exception {
// given
Object msg = new OutboundMessage() {
};
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
assertThat(result).isEqualTo(CONTINUE);
verify(handlerSpy, never()).executeResponseFilters(any());
}
use of com.nike.riposte.server.channelpipeline.message.OutboundMessage in project riposte by Nike-Inc.
the class ResponseFilterHandlerTest method doChannelRead_delegates_to_executeResponseFilters_and_returns_CONTINUE_if_msg_is_first_chunk_of_response.
@DataProvider(value = { "true", "false" }, splitBy = "\\|")
@Test
public void doChannelRead_delegates_to_executeResponseFilters_and_returns_CONTINUE_if_msg_is_first_chunk_of_response(boolean chunkedResponse) throws Exception {
// given
OutboundMessage msg = (chunkedResponse) ? mock(OutboundMessageSendHeadersChunkFromResponseInfo.class) : mock(LastOutboundMessageSendFullResponseInfo.class);
doNothing().when(handlerSpy).executeResponseFilters(any());
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
assertThat(result).isEqualTo(CONTINUE);
verify(handlerSpy).executeResponseFilters(ctxMock);
}
use of com.nike.riposte.server.channelpipeline.message.OutboundMessage in project riposte by Nike-Inc.
the class RequestHasBeenHandledVerificationHandler method doChannelRead.
@Override
public PipelineContinuationBehavior doChannelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg == null) {
throw new InvalidRipostePipelineException("msg cannot be null at this stage of the pipeline. An endpoint handler should have fired a valid " + "OutboundMessage. invalid_riposte_pipeline=true");
}
if (!(msg instanceof OutboundMessage)) {
throw new InvalidRipostePipelineException("Expected msg to be a OutboundMessage, but instead found: " + msg.getClass().getName() + ". invalid_riposte_pipeline=true");
}
HttpProcessingState state = ChannelAttributes.getHttpProcessingStateForChannel(ctx).get();
if (state == null) {
throw new InvalidRipostePipelineException("Found null HttpProcessingState in the channel, which is not allowed at this point. " + "invalid_riposte_pipeline=true");
}
ResponseInfo<?> responseInfo = state.getResponseInfo();
if (responseInfo == null) {
throw new InvalidRipostePipelineException("Found null ResponseInfo in the channel state, which is not allowed at this point. " + "An endpoint handler should have set a ResponseInfo on the state. invalid_riposte_pipeline=true");
}
if (responseInfo.isChunkedResponse() && !(msg instanceof ChunkedOutboundMessage)) {
throw new InvalidRipostePipelineException("ResponseInfo.isChunkedResponse() indicates a chunked response, but the message was not a " + "ChunkedOutboundMessage. msg_type=" + msg.getClass().getName() + ", invalid_riposte_pipeline=true");
}
if (!responseInfo.isChunkedResponse() && !(msg instanceof LastOutboundMessageSendFullResponseInfo)) {
throw new InvalidRipostePipelineException("ResponseInfo.isChunkedResponse() indicates a full response, but the message was not a " + "LastOutboundMessageSendFullResponseInfo. msg_type=" + msg.getClass().getName() + ", invalid_riposte_pipeline=true");
}
return CONTINUE;
}
Aggregations