use of org.assertj.core.api.Assertions.catchThrowable in project riposte by Nike-Inc.
the class RoutingHandlerTest method doChannelRead_HttpRequest_throws_exception_when_failed_decoder_result.
@Test
public void doChannelRead_HttpRequest_throws_exception_when_failed_decoder_result() {
// given
HttpRequest msgMock = mock(HttpRequest.class);
Throwable decoderFailureCauseMock = mock(Throwable.class);
DecoderResult decoderResult = DecoderResult.failure(decoderFailureCauseMock);
doReturn(decoderResult).when(msgMock).decoderResult();
doReturn(null).when(stateMock).getRequestInfo();
// when
Throwable thrownException = Assertions.catchThrowable(() -> handlerSpy.doChannelRead(ctxMock, msgMock));
// then
assertThat(thrownException).isExactlyInstanceOf(InvalidHttpRequestException.class);
assertThat(thrownException.getCause()).isSameAs(decoderFailureCauseMock);
}
use of org.assertj.core.api.Assertions.catchThrowable in project riposte by Nike-Inc.
the class RoutingHandlerTest method doChannelRead_HttpRequest_throws_exception_when_content_length_header_greater_than_configured_global_request_limit.
@Test
public void doChannelRead_HttpRequest_throws_exception_when_content_length_header_greater_than_configured_global_request_limit() {
// given
doReturn(null).when(endpointMock).maxRequestSizeInBytesOverride();
maxRequestSizeInBytes = 10;
httpHeaders.set(CONTENT_LENGTH, 100);
handlerSpy = spy(new RoutingHandler(endpoints, maxRequestSizeInBytes, distributedTracingConfigMock));
// when
Throwable thrownException = Assertions.catchThrowable(() -> handlerSpy.doChannelRead(ctxMock, msg));
// then
assertThat(thrownException).isExactlyInstanceOf(RequestTooBigException.class);
assertThat(thrownException.getMessage()).isEqualTo("Content-Length header value exceeded configured max request size of 10");
}
use of org.assertj.core.api.Assertions.catchThrowable in project riposte by Nike-Inc.
the class RoutingHandlerTest method doChannelRead_HttpRequest_endpoint_overridden_max_request_size_throws_exception.
@DataProvider(value = { "99", "101" })
@Test
public void doChannelRead_HttpRequest_endpoint_overridden_max_request_size_throws_exception(int maxRequestSize) {
// given
doReturn(100).when(endpointMock).maxRequestSizeInBytesOverride();
httpHeaders.set(CONTENT_LENGTH, 101);
handlerSpy = spy(new RoutingHandler(endpoints, maxRequestSize, distributedTracingConfigMock));
// when
Throwable thrownException = Assertions.catchThrowable(() -> handlerSpy.doChannelRead(ctxMock, msg));
// then
assertThat(thrownException).isExactlyInstanceOf(RequestTooBigException.class);
assertThat(thrownException.getMessage()).isEqualTo("Content-Length header value exceeded configured max request size of 100");
}
Aggregations