Search in sources :

Example 66 with PipelineContinuationBehavior

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);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Span(com.nike.wingtips.Span) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Example 67 with PipelineContinuationBehavior

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);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 68 with PipelineContinuationBehavior

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);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 69 with PipelineContinuationBehavior

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);
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 70 with PipelineContinuationBehavior

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);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Aggregations

PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)75 Test (org.junit.Test)73 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)20 RequestInfo (com.nike.riposte.server.http.RequestInfo)5 Span (com.nike.wingtips.Span)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 LastOutboundMessageSendFullResponseInfo (com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)4 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)4 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)4 RequestAndResponseFilter (com.nike.riposte.server.http.filter.RequestAndResponseFilter)4 ChannelFuture (io.netty.channel.ChannelFuture)4 HttpObject (io.netty.handler.codec.http.HttpObject)4 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)4 Pair (com.nike.internal.util.Pair)3 HttpContent (io.netty.handler.codec.http.HttpContent)3 ChannelAttributes (com.nike.riposte.server.channelpipeline.ChannelAttributes)2 OutboundMessage (com.nike.riposte.server.channelpipeline.message.OutboundMessage)2 OutboundMessageSendHeadersChunkFromResponseInfo (com.nike.riposte.server.channelpipeline.message.OutboundMessageSendHeadersChunkFromResponseInfo)2 IncompleteHttpCallTimeoutException (com.nike.riposte.server.error.exception.IncompleteHttpCallTimeoutException)2 TooManyOpenChannelsException (com.nike.riposte.server.error.exception.TooManyOpenChannelsException)2