Search in sources :

Example 21 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class ResponseFilterHandlerTest method doExceptionCaught_delegates_to_executeResponseFilters_and_returns_CONTINUE.

@Test
public void doExceptionCaught_delegates_to_executeResponseFilters_and_returns_CONTINUE() throws Exception {
    // given
    Throwable ex = mock(Throwable.class);
    doNothing().when(handlerSpy).executeResponseFilters(any());
    // when
    PipelineContinuationBehavior result = handlerSpy.doExceptionCaught(ctxMock, ex);
    // then
    assertThat(result).isEqualTo(CONTINUE);
    verify(handlerSpy).executeResponseFilters(ctxMock);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 22 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior 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);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) OutboundMessageSendHeadersChunkFromResponseInfo(com.nike.riposte.server.channelpipeline.message.OutboundMessageSendHeadersChunkFromResponseInfo) OutboundMessage(com.nike.riposte.server.channelpipeline.message.OutboundMessage) LastOutboundMessageSendFullResponseInfo(com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Example 23 with PipelineContinuationBehavior

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

Example 24 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class OpenChannelLimitHandlerTest method doChannelActive_adds_channel_to_channelGroup_if_open_channel_count_lower_than_max_threshold.

@Test
public void doChannelActive_adds_channel_to_channelGroup_if_open_channel_count_lower_than_max_threshold() throws Exception {
    // given
    setActualOpenChannels(maxOpenChannelsThreshold - 1);
    // when
    PipelineContinuationBehavior result = handler.doChannelActive(ctxMock);
    // then
    assertThat(result).isEqualTo(CONTINUE);
    verify(channelGroupMock).add(channelMock);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) Test(org.junit.Test)

Example 25 with PipelineContinuationBehavior

use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.

the class OpenChannelLimitHandlerTest method doChannelActive_marks_and_schedules_double_check_timeout_if_too_many_open_channels.

@DataProvider(value = { "0", "1" })
@Test
public void doChannelActive_marks_and_schedules_double_check_timeout_if_too_many_open_channels(int numOpenChannelsGreaterThanMax) throws Exception {
    // given
    int actualOpenChannels = maxOpenChannelsThreshold + numOpenChannelsGreaterThanMax;
    setActualOpenChannels(actualOpenChannels);
    // when
    PipelineContinuationBehavior result = handler.doChannelActive(ctxMock);
    // then
    assertThat(result).isEqualTo(CONTINUE);
    Pair<Runnable, GenericFutureListener> futureInfoPair = extractDoubleCheckRunnableAndCloseFutureListener();
    verify(tooManyOpenConnectionsAttributeMock).set(actualOpenChannels);
    verifyDoubleCheckFuture(futureInfoPair.getLeft());
    verifyCloseFutureListener(futureInfoPair.getRight());
    verify(channelGroupMock, never()).add(channelMock);
}
Also used : PipelineContinuationBehavior(com.nike.riposte.server.handler.base.PipelineContinuationBehavior) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test)

Aggregations

PipelineContinuationBehavior (com.nike.riposte.server.handler.base.PipelineContinuationBehavior)92 Test (org.junit.Test)90 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)26 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)11 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)9 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)8 RequestInfo (com.nike.riposte.server.http.RequestInfo)7 Span (com.nike.wingtips.Span)6 IncompleteHttpCallTimeoutException (com.nike.riposte.server.error.exception.IncompleteHttpCallTimeoutException)5 TooManyOpenChannelsException (com.nike.riposte.server.error.exception.TooManyOpenChannelsException)5 ErrorResponseBody (com.nike.riposte.server.error.handler.ErrorResponseBody)5 RequestAndResponseFilter (com.nike.riposte.server.http.filter.RequestAndResponseFilter)5 HttpRequest (io.netty.handler.codec.http.HttpRequest)5 Pair (com.nike.internal.util.Pair)4 LastOutboundMessageSendFullResponseInfo (com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)4 ResponseInfo (com.nike.riposte.server.http.ResponseInfo)4 ChannelFuture (io.netty.channel.ChannelFuture)4 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)4 InvalidRipostePipelineException (com.nike.riposte.server.error.exception.InvalidRipostePipelineException)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)3