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);
  }
示例#3
0
 @Override
 public ChannelFuture sendFile(FileRegion region, ChannelFuture future) {
   return pipeline.sendFile(region, future);
 }
示例#4
0
 @Override
 public ChannelFuture write(Object message, ChannelFuture future) {
   return pipeline.write(message, future);
 }
示例#5
0
 @Override
 public ChannelFuture flush(ChannelFuture future) {
   return pipeline.flush(future);
 }
示例#6
0
 @Override
 @SuppressWarnings("unchecked")
 public <T> MessageBuf<T> outboundMessageBuffer() {
   return (MessageBuf<T>) pipeline.outboundMessageBuffer();
 }
示例#7
0
 @Override
 public ByteBuf outboundByteBuffer() {
   return pipeline.outboundByteBuffer();
 }
示例#8
0
 @Override
 public ChannelFuture deregister(ChannelFuture future) {
   return pipeline.deregister(future);
 }
示例#9
0
 @Override
 public ChannelFuture close(ChannelFuture future) {
   return pipeline.close(future);
 }
示例#10
0
 @Override
 public ChannelFuture disconnect(ChannelFuture future) {
   return pipeline.disconnect(future);
 }
示例#11
0
 @Override
 public ChannelFuture connect(
     SocketAddress remoteAddress, SocketAddress localAddress, ChannelFuture future) {
   return pipeline.connect(remoteAddress, localAddress, future);
 }
示例#12
0
 @Override
 public ChannelFuture bind(SocketAddress localAddress, ChannelFuture future) {
   return pipeline.bind(localAddress, future);
 }
示例#13
0
 @Override
 public ChannelFuture close() {
   return pipeline.close();
 }
示例#14
0
 @Override
 public ChannelFuture connect(SocketAddress remoteAddress) {
   return pipeline.connect(remoteAddress);
 }