Example usage for io.netty.channel ChannelHandlerAdapter ChannelHandlerAdapter

List of usage examples for io.netty.channel ChannelHandlerAdapter ChannelHandlerAdapter

Introduction

In this page you can find the example usage for io.netty.channel ChannelHandlerAdapter ChannelHandlerAdapter.

Prototype

ChannelHandlerAdapter

Source Link

Usage

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addByteDecoderWhenNoLeft() throws Exception {

    channel.pipeline().addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });/*from   ww  w.  ja  v  a  2  s .  c om*/
    ChannelHandler decoder = new LineBasedFrameDecoder(12);

    testContext.addHandlerLast("decoder", decoder).addHandlerFirst("decoder$extract",
            NettyPipeline.inboundHandler(ADD_EXTRACTOR));

    assertEquals(channel.pipeline().names(), Arrays.asList("decoder$extract", "decoder",
            NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addByteDecoderWhenNoRight() throws Exception {

    channel.pipeline().addLast(NettyPipeline.HttpDecoder, new ChannelHandlerAdapter() {
    });/*from w w w  .ja  va 2 s  .  co  m*/
    ChannelHandler decoder = new LineBasedFrameDecoder(12);

    testContext.addHandlerLast("decoder", decoder).addHandlerFirst("decoder$extract",
            NettyPipeline.inboundHandler(ADD_EXTRACTOR));

    assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpDecoder, "decoder$extract",
            "decoder", "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addByteDecoderWhenFullReactorPipeline() 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 .  j a va  2s.  com*/
    ChannelHandler decoder = new LineBasedFrameDecoder(12);

    testContext.addHandlerLast("decoder", decoder).addHandlerFirst("decoder$extract",
            NettyPipeline.inboundHandler(ADD_EXTRACTOR));

    assertEquals(channel.pipeline().names(),
            Arrays.asList(NettyPipeline.HttpDecoder, NettyPipeline.HttpEncoder, NettyPipeline.HttpServerHandler,
                    "decoder$extract", "decoder", NettyPipeline.ReactiveBridge,
                    "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addNonByteDecoderWhenNoLeft() throws Exception {

    channel.pipeline().addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });//from w ww.j a  va 2 s.  c o m
    ChannelHandler decoder = new ChannelHandlerAdapter() {
    };

    testContext.addHandlerLast("decoder", decoder);

    assertEquals(channel.pipeline().names(),
            Arrays.asList("decoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addNonByteDecoderWhenNoRight() throws Exception {

    channel.pipeline().addLast(NettyPipeline.HttpDecoder, new ChannelHandlerAdapter() {
    });//from w  w w. j av  a 2  s  .  c o  m
    ChannelHandler decoder = new ChannelHandlerAdapter() {
    };

    testContext.addHandlerLast("decoder", decoder);

    assertEquals(channel.pipeline().names(),
            Arrays.asList(NettyPipeline.HttpDecoder, "decoder", "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addNonByteDecoderWhenEmptyPipeline() throws Exception {

    ChannelHandler decoder = new ChannelHandlerAdapter() {
    };/* w w  w  .  j  av  a  2 s. c om*/

    testContext.addHandlerLast("decoder", decoder);

    assertEquals(channel.pipeline().names(), Arrays.asList("decoder", "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addNonByteDecoderWhenFullReactorPipeline() 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.  j ava 2  s .com*/
    ChannelHandler decoder = new ChannelHandlerAdapter() {
    };

    testContext.addHandlerLast("decoder", decoder);

    assertEquals(channel.pipeline().names(),
            Arrays.asList(NettyPipeline.HttpDecoder, NettyPipeline.HttpEncoder, NettyPipeline.HttpServerHandler,
                    "decoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addSeveralByteDecodersWhenCodec() throws Exception {
    ChannelHandler decoder1 = new LineBasedFrameDecoder(12);
    ChannelHandler decoder2 = 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() {
            });/*from  w  w  w .ja va 2s  .  co  m*/

    testContext.addHandlerLast("decoder1$extract", NettyPipeline.inboundHandler(ADD_EXTRACTOR))
            .addHandlerLast("decoder1", decoder1)

            .addHandlerLast("decoder2$extract", NettyPipeline.inboundHandler(ADD_EXTRACTOR))
            .addHandlerLast("decoder2", decoder2);

    assertEquals(channel.pipeline().names(),
            Arrays.asList(NettyPipeline.HttpDecoder, NettyPipeline.HttpEncoder, NettyPipeline.HttpServerHandler,
                    "decoder1$extract", "decoder1", "decoder2$extract", "decoder2",
                    NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}

From source file:reactor.ipc.netty.NettyContextTest.java

License:Open Source License

@Test
public void addByteEncoderWhenNoLeft() throws Exception {

    channel.pipeline().addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });// www  .  j a  v a 2  s .  c o m
    ChannelHandler encoder = new LineBasedFrameDecoder(12);

    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 addByteEncoderWhenNoRight() throws Exception {

    channel.pipeline().addLast(NettyPipeline.HttpDecoder, new ChannelHandlerAdapter() {
    });/*ww  w .  j  a  v  a 2 s .  c om*/
    ChannelHandler encoder = new LineBasedFrameDecoder(12);

    testContext.addHandlerFirst("encoder", encoder);

    assertEquals(channel.pipeline().names(),
            Arrays.asList(NettyPipeline.HttpDecoder, "encoder", "DefaultChannelPipeline$TailContext#0"));
}