use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class ChannelPipelineFinalizerHandlerTest method doChannelInactive_does_not_try_to_recomplete_span_if_already_completed.
@Test
public void doChannelInactive_does_not_try_to_recomplete_span_if_already_completed() throws Exception {
// given
Span span = setupTracingForChannelInactive(false);
Deque<Span> deque = new LinkedList<>();
deque.add(span);
Tracer.getInstance().registerWithThread(deque);
Tracer.getInstance().completeRequestSpan();
Assertions.assertThat(span.isCompleted()).isTrue();
long durationNanosBefore = span.getDurationNanos();
// when
PipelineContinuationBehavior result = handler.doChannelInactive(ctxMock);
// then
// no change
Assertions.assertThat(span.isCompleted()).isTrue();
Assertions.assertThat(span.getDurationNanos()).isEqualTo(durationNanosBefore);
verify(requestInfoMock).releaseAllResources();
verify(proxyRouterStateMock).setStreamingFailed();
verify(proxyRouterStateMock).triggerStreamingChannelErrorForChunks(any(Throwable.class));
Assertions.assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior 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));
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class DTraceEndHandlerTest method doChannelRead_does_nothing_and_returns_CONTINUE_if_msg_is_not_LastOutboundMessage.
@Test
public void doChannelRead_does_nothing_and_returns_CONTINUE_if_msg_is_not_LastOutboundMessage() throws Exception {
// given
Object msg = new Object();
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
verify(handlerSpy, times(0)).endDtrace(ctxMock);
assertThat(result, is(PipelineContinuationBehavior.CONTINUE));
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class ChannelPipelineFinalizerHandlerTest method doExceptionCaught_gets_state_from_getStateAndCreateIfNeeded_method_and_then_calls_finalizeChannelPipeline_and_then_returns_DO_NOT_FIRE_CONTINUE_EVENT.
@Test
public void doExceptionCaught_gets_state_from_getStateAndCreateIfNeeded_method_and_then_calls_finalizeChannelPipeline_and_then_returns_DO_NOT_FIRE_CONTINUE_EVENT() throws Exception {
// given
ChannelPipelineFinalizerHandler handlerSpy = spy(handler);
Exception cause = new Exception("intentional test exception");
state.setResponseWriterFinalChunkChannelFuture(mock(ChannelFuture.class));
// when
PipelineContinuationBehavior result = handlerSpy.doExceptionCaught(ctxMock, cause);
// then
verify(handlerSpy).getStateAndCreateIfNeeded(ctxMock, cause);
verify(handlerSpy).finalizeChannelPipeline(ctxMock, null, state, cause);
assertThat(result, is(PipelineContinuationBehavior.DO_NOT_FIRE_CONTINUE_EVENT));
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class ChannelPipelineFinalizerHandlerTest method doChannelInactive_does_what_it_can_when_the_RequestInfo_or_ResponseInfo_is_null.
@DataProvider(value = { "true | false", "false | true", "true | true" }, splitBy = "\\|")
@Test
public void doChannelInactive_does_what_it_can_when_the_RequestInfo_or_ResponseInfo_is_null(boolean requestInfoIsNull, boolean responseInfoIsNull) throws Exception {
// given
Span span = setupTracingForChannelInactive(false);
if (requestInfoIsNull)
state.setRequestInfo(null);
if (responseInfoIsNull)
state.setResponseInfo(null);
// when
PipelineContinuationBehavior result = handler.doChannelInactive(ctxMock);
// then
Assertions.assertThat(span.isCompleted()).isTrue();
Assertions.assertThat(state.isTraceCompletedOrScheduled()).isTrue();
if (requestInfoIsNull)
verifyZeroInteractions(requestInfoMock);
else
verify(requestInfoMock).releaseAllResources();
verify(proxyRouterStateMock).setStreamingFailed();
verify(proxyRouterStateMock).triggerStreamingChannelErrorForChunks(any(Throwable.class));
Assertions.assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Aggregations