Java Code Examples for io.netty.handler.codec.DecoderResult#failure()
The following examples show how to use
io.netty.handler.codec.DecoderResult#failure() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestInfoSetterHandlerTest.java From riposte with Apache License 2.0 | 6 votes |
@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(() -> handler.doChannelRead(ctxMock, msgMock)); // then assertThat(thrownException).isExactlyInstanceOf(InvalidHttpRequestException.class); assertThat(thrownException.getCause()).isSameAs(decoderFailureCauseMock); }
Example 2
Source File: RoutingHandlerTest.java From riposte with Apache License 2.0 | 6 votes |
@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); }
Example 3
Source File: RequestInfoSetterHandlerTest.java From riposte with Apache License 2.0 | 5 votes |
@Test public void doChannelRead_HttpContent_throws_exception_when_failed_decoder_result() { // given Throwable decoderFailureCauseMock = mock(Throwable.class); DecoderResult decoderResult = DecoderResult.failure(decoderFailureCauseMock); doReturn(decoderResult).when(httpContentMock).decoderResult(); // when Throwable thrownException = Assertions.catchThrowable(() -> handler.doChannelRead(ctxMock, httpContentMock)); // then assertThat(thrownException).isExactlyInstanceOf(InvalidHttpRequestException.class); assertThat(thrownException.getCause()).isSameAs(decoderFailureCauseMock); verify(httpContentMock).release(); }
Example 4
Source File: RequestFilterHandlerTest.java From riposte with Apache License 2.0 | 5 votes |
@Test public void doChannelRead_HttpRequest_throws_exception_when_failed_decoder_result() { // given Throwable decoderFailureCauseMock = mock(Throwable.class); DecoderResult decoderResult = DecoderResult.failure(decoderFailureCauseMock); doReturn(decoderResult).when(firstChunkMsgMock).decoderResult(); state.setRequestInfo(null); // when Throwable thrownException = Assertions.catchThrowable(() -> handlerSpy.doChannelRead(ctxMock, firstChunkMsgMock)); // then assertThat(thrownException).isExactlyInstanceOf(InvalidHttpRequestException.class); assertThat(thrownException.getCause()).isSameAs(decoderFailureCauseMock); }
Example 5
Source File: MqttMessageFactory.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
public static MqttMessage newInvalidMessage(Throwable cause) { return new MqttMessage(null, null, null, DecoderResult.failure(cause)); }
Example 6
Source File: MqttMessageFactory.java From mithqtt with Apache License 2.0 | 4 votes |
public static MqttMessage newInvalidMessage(Throwable cause) { return new MqttMessage(null, null, null, DecoderResult.failure(cause)); }