List of usage examples for io.netty.channel ChannelHandlerAdapter ChannelHandlerAdapter
ChannelHandlerAdapter
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void addByteEncoderWhenFullReactorPipeline() throws Exception { channel.pipeline().addLast(NettyPipeline.HttpDecoder, new HttpRequestDecoder()) .addLast(NettyPipeline.HttpEncoder, new HttpResponseEncoder()) .addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()) .addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() { });//from w w w.jav a 2 s . c om ChannelHandler encoder = new LineBasedFrameDecoder(12); testContext.addHandlerFirst("encoder", encoder); assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpDecoder, NettyPipeline.HttpEncoder, NettyPipeline.HttpServerHandler, "encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0")); }
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void addNonByteEncoderWhenNoLeft() throws Exception { channel.pipeline().addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() { });/*from ww w .j av a 2 s . com*/ ChannelHandler encoder = new ChannelHandlerAdapter() { }; testContext.addHandlerFirst("encoder", encoder); assertEquals(channel.pipeline().names(), Arrays.asList("encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0")); }
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void addNonByteEncoderWhenNoRight() throws Exception { channel.pipeline().addLast(NettyPipeline.HttpDecoder, new ChannelHandlerAdapter() { });/*from w ww .j a v a 2 s . c om*/ ChannelHandler encoder = new ChannelHandlerAdapter() { }; testContext.addHandlerFirst("encoder", encoder); assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpDecoder, "encoder", "DefaultChannelPipeline$TailContext#0")); }
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void addNonByteEncoderWhenEmptyPipeline() throws Exception { ChannelHandler encoder = new ChannelHandlerAdapter() { };/*w ww. java2s. c o m*/ testContext.addHandlerFirst("encoder", encoder); assertEquals(channel.pipeline().names(), Arrays.asList("encoder", "DefaultChannelPipeline$TailContext#0")); }
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void addNonByteEncoderWhenFullReactorPipeline() throws Exception { channel.pipeline().addLast(NettyPipeline.HttpDecoder, new HttpRequestDecoder()) .addLast(NettyPipeline.HttpEncoder, new HttpResponseEncoder()) .addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()) .addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() { });// w w w .ja va 2 s.c o m ChannelHandler encoder = new ChannelHandlerAdapter() { }; testContext.addHandlerFirst("encoder", encoder); assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpDecoder, NettyPipeline.HttpEncoder, NettyPipeline.HttpServerHandler, "encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0")); }
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void addSeveralByteEncodersWhenCodec() throws Exception { ChannelHandler encoder1 = new LineBasedFrameDecoder(12); ChannelHandler encoder2 = new LineBasedFrameDecoder(13); channel.pipeline().addLast(NettyPipeline.HttpDecoder, new HttpRequestDecoder()) .addLast(NettyPipeline.HttpEncoder, new HttpResponseEncoder()) .addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()) .addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() { });// ww w .j a v a 2 s . com testContext.addHandlerFirst("encoder1", encoder1).addHandlerFirst("encoder2", encoder2); assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpDecoder, NettyPipeline.HttpEncoder, NettyPipeline.HttpServerHandler, "encoder2", "encoder1", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0")); }
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void encoderSupportSkipsOnCloseIfAttributeClosedChannel() { AtomicLong closeCount = new AtomicLong(); NettyContext c = new NettyContext() { @Override/*from www .j av a 2s . com*/ public Channel channel() { return channel; } @Override public NettyContext onClose(Runnable onClose) { closeCount.incrementAndGet(); return this; } @Override public NettyContext removeHandler(String name) { return this; } }; c.markPersistent(false).addHandlerFirst("byteencoder", new Utf8FrameValidator()).addHandlerFirst("encoder", new ChannelHandlerAdapter() { }); assertThat(NettyContext.isPersistent(channel), is(false)); assertThat(closeCount.intValue(), is(0)); }
From source file:reactor.ipc.netty.NettyContextTest.java
License:Open Source License
@Test public void decoderSupportSkipsOnCloseIfAttributeClosedChannel() { AtomicLong closeCount = new AtomicLong(); NettyContext c = new NettyContext() { @Override/* ww w . ja v a 2 s .com*/ public Channel channel() { return channel; } @Override public NettyContext onClose(Runnable onClose) { closeCount.incrementAndGet(); return this; } @Override public NettyContext removeHandler(String name) { return this; } }; c.markPersistent(false).addHandlerLast("byteDecoder", new Utf8FrameValidator()).addHandlerLast("decoder", new ChannelHandlerAdapter() { }); assertThat(NettyContext.isPersistent(channel), is(false)); assertThat(closeCount.intValue(), is(0)); }