private static DefaultChannelPipeline createPipeline(Channel ch) { DefaultChannelPipeline pipeline = new DefaultChannelPipeline(ch); pipeline.addLast("chunkAggregator", new HttpChunkAggregator(42)); pipeline.addLast("requestDecoder", new HttpRequestDecoder()); pipeline.addLast("responseEncoder", new HttpResponseEncoder()); return pipeline; }
@Test public void testReplaceChannelHandler() { DefaultChannelPipeline pipeline = new DefaultChannelPipeline(); SimpleChannelHandler handler1 = new SimpleChannelHandler(); pipeline.addLast("handler1", handler1); pipeline.addLast("handler2", handler1); pipeline.addLast("handler3", handler1); assertTrue(pipeline.get("handler1") == handler1); assertTrue(pipeline.get("handler2") == handler1); assertTrue(pipeline.get("handler3") == handler1); SimpleChannelHandler newHandler1 = new SimpleChannelHandler(); pipeline.replace("handler1", "handler1", newHandler1); assertTrue(pipeline.get("handler1") == newHandler1); SimpleChannelHandler newHandler3 = new SimpleChannelHandler(); pipeline.replace("handler3", "handler3", newHandler3); assertTrue(pipeline.get("handler3") == newHandler3); SimpleChannelHandler newHandler2 = new SimpleChannelHandler(); pipeline.replace("handler2", "handler2", newHandler2); assertTrue(pipeline.get("handler2") == newHandler2); }
@Override public ChannelFuture sendFile(FileRegion region, ChannelFuture future) { return pipeline.sendFile(region, future); }
@Override public ChannelFuture write(Object message, ChannelFuture future) { return pipeline.write(message, future); }
@Override public ChannelFuture flush(ChannelFuture future) { return pipeline.flush(future); }
@Override @SuppressWarnings("unchecked") public <T> MessageBuf<T> outboundMessageBuffer() { return (MessageBuf<T>) pipeline.outboundMessageBuffer(); }
@Override public ByteBuf outboundByteBuffer() { return pipeline.outboundByteBuffer(); }
@Override public ChannelFuture deregister(ChannelFuture future) { return pipeline.deregister(future); }
@Override public ChannelFuture close(ChannelFuture future) { return pipeline.close(future); }
@Override public ChannelFuture disconnect(ChannelFuture future) { return pipeline.disconnect(future); }
@Override public ChannelFuture connect( SocketAddress remoteAddress, SocketAddress localAddress, ChannelFuture future) { return pipeline.connect(remoteAddress, localAddress, future); }
@Override public ChannelFuture bind(SocketAddress localAddress, ChannelFuture future) { return pipeline.bind(localAddress, future); }
@Override public ChannelFuture close() { return pipeline.close(); }
@Override public ChannelFuture connect(SocketAddress remoteAddress) { return pipeline.connect(remoteAddress); }