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_HttpProcessingState_or_ProxyRouterProcessingState_is_null.
@DataProvider(value = { "true | false", "false | true", "true | true" }, splitBy = "\\|")
@Test
public void doChannelInactive_does_what_it_can_when_the_HttpProcessingState_or_ProxyRouterProcessingState_is_null(boolean httpStateIsNull, boolean proxyRouterStateIsNull) throws Exception {
// given
if (httpStateIsNull)
doReturn(null).when(stateAttributeMock).get();
if (proxyRouterStateIsNull)
doReturn(null).when(proxyRouterProcessingStateAttributeMock).get();
Span span = setupTracingForChannelInactive(false);
// when
PipelineContinuationBehavior result = handler.doChannelInactive(ctxMock);
// then
if (httpStateIsNull)
Assertions.assertThat(span.isCompleted()).isFalse();
else
Assertions.assertThat(span.isCompleted()).isTrue();
if (httpStateIsNull)
verifyZeroInteractions(requestInfoMock);
else
verify(requestInfoMock).releaseAllResources();
if (proxyRouterStateIsNull)
verifyZeroInteractions(proxyRouterStateMock);
else {
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 ChannelPipelineFinalizerHandlerTest method doChannelInactive_does_not_explode_if_span_is_missing.
@Test
public void doChannelInactive_does_not_explode_if_span_is_missing() throws Exception {
// given
Assertions.assertThat(state.getDistributedTraceStack()).isNull();
// when
PipelineContinuationBehavior result = handler.doChannelInactive(ctxMock);
// then
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 ResponseSenderHandlerTest method doChannelRead_calls_sendResponse_and_returns_CONTINUE.
@Test
public void doChannelRead_calls_sendResponse_and_returns_CONTINUE() throws Exception {
// given
Object msg = new Object();
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
verify(handlerSpy).sendResponse(ctxMock, msg);
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class RoutingHandlerTest method doChannelRead_calls_findSingleEndpointForExecution_then_sets_path_params_and_endpoint_on_state_then_returns_CONTINUE_if_msg_is_HttpRequest.
@Test
public void doChannelRead_calls_findSingleEndpointForExecution_then_sets_path_params_and_endpoint_on_state_then_returns_CONTINUE_if_msg_is_HttpRequest() {
// given
doReturn(Arrays.asList(defaultPath)).when(matcherMock).matchingPathTemplates();
HttpRequest msg = mock(HttpRequest.class);
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
verify(handlerSpy).findSingleEndpointForExecution(requestInfoMock);
verify(requestInfoMock).setPathParamsBasedOnPathTemplate(defaultPath);
verify(stateMock).setEndpointForExecution(endpointMock, defaultPath);
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class RoutingHandlerTest method doChannelRead_HttpRequest_under_max_global_request_size_processed_successfully.
@Test
public void doChannelRead_HttpRequest_under_max_global_request_size_processed_successfully() {
// given
doReturn(null).when(endpointMock).maxRequestSizeInBytesOverride();
maxRequestSizeInBytes = 101;
httpHeaders.set(CONTENT_LENGTH, 100);
handlerSpy = spy(new RoutingHandler(endpoints, maxRequestSizeInBytes));
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
Aggregations