use of io.netty.handler.codec.json.JsonObjectDecoder in project reactor-netty by reactor.
the class HttpClientOperationsTest method addNamedEncoderReplaysLastHttp.
@Test
public void addNamedEncoderReplaysLastHttp() throws Exception {
ByteBuf buf = Unpooled.copiedBuffer("{\"foo\":1}", CharsetUtil.UTF_8);
EmbeddedChannel channel = new EmbeddedChannel();
HttpClientOperations ops = new HttpClientOperations(channel, (response, request) -> null, handler);
ops.addHandler("json", new JsonObjectDecoder());
channel.writeInbound(new DefaultLastHttpContent(buf));
assertThat(channel.pipeline().names().iterator().next(), is("json$extractor"));
Object content = channel.readInbound();
assertThat(content, instanceOf(ByteBuf.class));
((ByteBuf) content).release();
content = channel.readInbound();
assertThat(content, instanceOf(LastHttpContent.class));
((LastHttpContent) content).release();
assertThat(channel.readInbound(), nullValue());
}
Aggregations