use of com.nike.riposte.server.channelpipeline.message.LastOutboundMessage in project riposte by Nike-Inc.
the class ChannelPipelineFinalizerHandlerTest method finalizeChannelPipeline_does_not_add_idle_channel_timeout_handler_to_pipeline_if_workerChannelIdleTimeoutMillis_is_not_greater_than_0_or_idle_timeout_handler_already_exists.
@DataProvider(value = { "0 | false", "-42 | false", "42 | true" }, splitBy = "\\|")
@Test
public void finalizeChannelPipeline_does_not_add_idle_channel_timeout_handler_to_pipeline_if_workerChannelIdleTimeoutMillis_is_not_greater_than_0_or_idle_timeout_handler_already_exists(long timeoutVal, boolean idleTimeoutHandlerAlreadyExists) throws JsonProcessingException {
// given
Whitebox.setInternalState(handler, "workerChannelIdleTimeoutMillis", timeoutVal);
LastOutboundMessage msg = mock(LastOutboundMessage.class);
if (idleTimeoutHandlerAlreadyExists)
doReturn(mock(ChannelHandler.class)).when(pipelineMock).get(IDLE_CHANNEL_TIMEOUT_HANDLER_NAME);
// when
handler.finalizeChannelPipeline(ctxMock, msg, state, null);
// then
verify(pipelineMock, never()).addFirst(anyString(), anyObject());
}
use of com.nike.riposte.server.channelpipeline.message.LastOutboundMessage in project riposte by Nike-Inc.
the class ChannelPipelineFinalizerHandlerTest method finalizeChannelPipeline_should_add_idle_channel_timeout_handler_first_in_pipeline_if_workerChannelIdleTimeoutMillis_is_greater_than_0.
@Test
public void finalizeChannelPipeline_should_add_idle_channel_timeout_handler_first_in_pipeline_if_workerChannelIdleTimeoutMillis_is_greater_than_0() throws JsonProcessingException {
// given
LastOutboundMessage msg = mock(LastOutboundMessage.class);
// when
handler.finalizeChannelPipeline(ctxMock, msg, state, null);
// then
ArgumentCaptor<ChannelHandler> idleHandlerArgCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
verify(pipelineMock).addFirst(eq(IDLE_CHANNEL_TIMEOUT_HANDLER_NAME), idleHandlerArgCaptor.capture());
ChannelHandler handlerRegistered = idleHandlerArgCaptor.getValue();
assertThat(handlerRegistered, instanceOf(IdleChannelTimeoutHandler.class));
IdleChannelTimeoutHandler idleHandler = (IdleChannelTimeoutHandler) handlerRegistered;
long idleValue = (long) Whitebox.getInternalState(idleHandler, "idleTimeoutMillis");
assertThat(idleValue, is(workerChannelIdleTimeoutMillis));
}
use of com.nike.riposte.server.channelpipeline.message.LastOutboundMessage in project riposte by Nike-Inc.
the class ChannelPipelineFinalizerHandlerTest method doChannelRead_gets_state_from_getStateAndCreateIfNeeded_method_and_then_calls_finalizeChannelPipeline_and_then_returns_DO_NOT_FIRE_CONTINUE_EVENT_if_msg_is_LastOutboundMessage.
@Test
public void doChannelRead_gets_state_from_getStateAndCreateIfNeeded_method_and_then_calls_finalizeChannelPipeline_and_then_returns_DO_NOT_FIRE_CONTINUE_EVENT_if_msg_is_LastOutboundMessage() throws Exception {
// given
ChannelPipelineFinalizerHandler handlerSpy = spy(handler);
LastOutboundMessage msg = mock(LastOutboundMessage.class);
state.setResponseWriterFinalChunkChannelFuture(mock(ChannelFuture.class));
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
verify(handlerSpy).finalizeChannelPipeline(eq(ctxMock), eq(msg), eq(state), any(Throwable.class));
assertThat(result, is(PipelineContinuationBehavior.DO_NOT_FIRE_CONTINUE_EVENT));
}
use of com.nike.riposte.server.channelpipeline.message.LastOutboundMessage in project riposte by Nike-Inc.
the class ChannelPipelineFinalizerHandler method doChannelRead.
@Override
public PipelineContinuationBehavior doChannelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof LastOutboundMessage) {
Exception ex = new Exception("Manually created exception to be used for diagnostic stack trace");
HttpProcessingState state = getStateAndCreateIfNeeded(ctx, ex);
finalizeChannelPipeline(ctx, msg, state, ex);
}
return PipelineContinuationBehavior.DO_NOT_FIRE_CONTINUE_EVENT;
}
use of com.nike.riposte.server.channelpipeline.message.LastOutboundMessage in project riposte by Nike-Inc.
the class DTraceEndHandlerTest method doChannelRead_calls_endDtrace_and_returns_CONTINUE_if_msg_is_LastOutboundMessage.
@Test
public void doChannelRead_calls_endDtrace_and_returns_CONTINUE_if_msg_is_LastOutboundMessage() throws Exception {
// given
LastOutboundMessage msg = mock(LastOutboundMessage.class);
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
verify(handlerSpy).endDtrace(ctxMock);
assertThat(result, is(PipelineContinuationBehavior.CONTINUE));
}
Aggregations