use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class RequestInfoSetterHandlerTest method doChannelRead_allows_endpoints_to_override_max_request_size_setting_higher.
@Test
public void doChannelRead_allows_endpoints_to_override_max_request_size_setting_higher() {
// given
maxRequestSizeInBytes = 10;
handler = new RequestInfoSetterHandler(maxRequestSizeInBytes);
doReturn(100).when(endpointMock).maxRequestSizeInBytesOverride();
doReturn(99).when(requestInfo).addContentChunk(any());
// when
PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, httpContentMock);
// then
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
verify(httpContentMock).release();
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class RequestInfoSetterHandlerTest method doChannelRead_override_uses_global_configured_max_request_size_when_necessary_no_error.
@DataProvider(value = { "true | false", "false | true" }, splitBy = "\\|")
@Test
public void doChannelRead_override_uses_global_configured_max_request_size_when_necessary_no_error(boolean endpointIsNull, boolean endpointReturnsNullOverride) {
// given
if (endpointIsNull)
doReturn(null).when(stateMock).getEndpointForExecution();
if (endpointReturnsNullOverride)
doReturn(null).when(endpointMock).maxRequestSizeInBytesOverride();
maxRequestSizeInBytes = 10;
handler = new RequestInfoSetterHandler(maxRequestSizeInBytes);
doReturn(5).when(requestInfo).addContentChunk(any());
// when
PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, httpContentMock);
// then
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
verify(httpContentMock).release();
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class RequestInfoSetterHandlerTest method doChannelRead_uses_existing_RequestInfo_on_state_if_available_and_does_not_recreate_it.
@Test
public void doChannelRead_uses_existing_RequestInfo_on_state_if_available_and_does_not_recreate_it() {
// given
HttpRequest msgMock = mock(HttpRequest.class);
String uri = "/some/url";
HttpHeaders headers = new DefaultHttpHeaders();
doReturn(uri).when(msgMock).uri();
doReturn(headers).when(msgMock).headers();
doReturn(HttpVersion.HTTP_1_1).when(msgMock).protocolVersion();
doReturn(requestInfo).when(stateMock).getRequestInfo();
// when
PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, msgMock);
// then
verify(stateMock, never()).setRequestInfo(any(RequestInfo.class));
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class RequestInfoSetterHandlerTest method doChannelRead_does_not_throw_exception_when_exceeding_global_max_size_when_request_validation_is_turned_off.
@Test
public void doChannelRead_does_not_throw_exception_when_exceeding_global_max_size_when_request_validation_is_turned_off() {
// given
maxRequestSizeInBytes = 10;
handler = new RequestInfoSetterHandler(maxRequestSizeInBytes);
doReturn(0).when(endpointMock).maxRequestSizeInBytesOverride();
doReturn(100).when(requestInfo).addContentChunk(any());
// when
PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, httpContentMock);
// then
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
verify(httpContentMock).release();
}
use of com.nike.riposte.server.handler.base.PipelineContinuationBehavior in project riposte by Nike-Inc.
the class RequestInfoSetterHandlerTest method doChannelRead_releases_content_and_returns_do_not_fire_when_state_is_null_or_response_already_sent_or_channel_is_inactive.
@DataProvider(value = { "true | false | false", "false | true | false", "true | true | false", "false | false | true" }, splitBy = "\\|")
@Test
public void doChannelRead_releases_content_and_returns_do_not_fire_when_state_is_null_or_response_already_sent_or_channel_is_inactive(boolean stateIsNull, boolean responseAlreadySent, boolean channelIsInactive) {
// given
if (stateIsNull) {
doReturn(null).when(stateAttrMock).get();
}
if (responseAlreadySent) {
doReturn(true).when(stateMock).isResponseSendingLastChunkSent();
}
if (channelIsInactive) {
doReturn(false).when(channelMock).isActive();
}
// when
PipelineContinuationBehavior result = handler.doChannelRead(ctxMock, httpContentMock);
// then
verify(httpContentMock).release();
assertThat(result).isEqualTo(PipelineContinuationBehavior.DO_NOT_FIRE_CONTINUE_EVENT);
}
Aggregations