use of io.netty.handler.codec.http.HttpObject in project cxf by apache.
the class NettyHttpClientHandler method channelRead.
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof HttpObject) {
if (msg instanceof HttpResponse) {
// just make sure we can combine the request and response together
HttpResponse response = (HttpResponse) msg;
NettyHttpClientRequest request = sendedQueue.poll();
request.setResponse(response);
// calling the callback here
request.getCxfResponseCallback().responseReceived(response);
}
if (msg instanceof LastHttpContent) {
ctx.close();
}
} else {
super.channelRead(ctx, msg);
}
}
use of io.netty.handler.codec.http.HttpObject in project riposte by Nike-Inc.
the class RiposteHandlerInternalUtilTest method getDecoderFailure_returns_DecoderResult_cause_when_it_is_a_failure.
@Test
public void getDecoderFailure_returns_DecoderResult_cause_when_it_is_a_failure() {
// given
HttpObject httpObjectMock = mock(HttpObject.class);
Throwable expectedResult = mock(Throwable.class);
doReturn(DecoderResult.failure(expectedResult)).when(httpObjectMock).decoderResult();
// when
Throwable result = implSpy.getDecoderFailure(httpObjectMock);
// then
assertThat(result).isEqualTo(expectedResult);
}
use of io.netty.handler.codec.http.HttpObject in project riposte by Nike-Inc.
the class RoutingHandlerTest method doChannelRead_does_nothing_if_msg_is_not_HttpRequest.
@Test
public void doChannelRead_does_nothing_if_msg_is_not_HttpRequest() {
// given
String pathTemplate = "/some/path/with/{id}";
Collection<String> pathTemplates = new ArrayList<String>() {
{
add(pathTemplate);
}
};
doReturn(pathTemplates).when(matcherMock).matchingPathTemplates();
HttpObject msg = mock(HttpObject.class);
// when
PipelineContinuationBehavior result = handlerSpy.doChannelRead(ctxMock, msg);
// then
verify(handlerSpy).doChannelRead(ctxMock, msg);
verifyNoMoreInteractions(handlerSpy);
verifyNoMoreInteractions(requestInfoMock);
verifyNoMoreInteractions(stateMock);
assertThat(result).isEqualTo(PipelineContinuationBehavior.CONTINUE);
}
use of io.netty.handler.codec.http.HttpObject in project riposte by Nike-Inc.
the class RiposteHandlerInternalUtilTest method getDecoderFailure_returns_null_when_DecoderResult_is_null.
@Test
public void getDecoderFailure_returns_null_when_DecoderResult_is_null() {
// given
HttpObject httpObjectMock = mock(HttpObject.class);
doReturn(null).when(httpObjectMock).decoderResult();
// when
Throwable result = implSpy.getDecoderFailure(httpObjectMock);
// then
assertThat(result).isNull();
}
use of io.netty.handler.codec.http.HttpObject in project riposte by Nike-Inc.
the class RiposteHandlerInternalUtilTest method getDecoderFailure_returns_null_when_DecoderResult_is_not_a_failure.
@DataProvider(value = { "true", "false" })
@Test
public void getDecoderFailure_returns_null_when_DecoderResult_is_not_a_failure(boolean isUnfinished) {
// given
HttpObject httpObjectMock = mock(HttpObject.class);
DecoderResult nonFailureDecoderResult = (isUnfinished) ? DecoderResult.UNFINISHED : DecoderResult.SUCCESS;
doReturn(nonFailureDecoderResult).when(httpObjectMock).decoderResult();
// when
Throwable result = implSpy.getDecoderFailure(httpObjectMock);
// then
assertThat(result).isNull();
}
Aggregations