Search in sources :

Example 26 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addNonByteEncoderWhenFullReactorPipeline.

@Test
public void addNonByteEncoderWhenFullReactorPipeline() throws Exception {
    channel.pipeline().addLast(NettyPipeline.HttpCodec, new HttpServerCodec()).addLast(NettyPipeline.HttpServerHandler, new ChannelDuplexHandler()).addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });
    ChannelHandler encoder = new ChannelHandlerAdapter() {
    };
    testContext.addHandlerFirst("encoder", encoder);
    assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, NettyPipeline.HttpServerHandler, "encoder", NettyPipeline.ReactiveBridge, "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 27 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addNonByteEncoderWhenNoRight.

@Test
public void addNonByteEncoderWhenNoRight() throws Exception {
    channel.pipeline().addLast(NettyPipeline.HttpCodec, new ChannelHandlerAdapter() {
    });
    ChannelHandler encoder = new ChannelHandlerAdapter() {
    };
    testContext.addHandlerFirst("encoder", encoder);
    assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, "encoder", "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 28 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addByteDecoderWhenNoRight.

@Test
public void addByteDecoderWhenNoRight() throws Exception {
    channel.pipeline().addLast(NettyPipeline.HttpCodec, new ChannelHandlerAdapter() {
    });
    ChannelHandler decoder = new LineBasedFrameDecoder(12);
    testContext.addHandlerLast("decoder", decoder).addHandlerFirst("decoder$extract", NettyPipeline.inboundHandler(ADD_EXTRACTOR));
    assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, "decoder$extract", "decoder", "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 29 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addByteDecoderWhenNoLeft.

@Test
public void addByteDecoderWhenNoLeft() throws Exception {
    channel.pipeline().addLast(NettyPipeline.ReactiveBridge, new ChannelHandlerAdapter() {
    });
    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"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Example 30 with ChannelHandler

use of io.netty.channel.ChannelHandler in project reactor-netty by reactor.

the class NettyContextTest method addByteEncoderWhenNoRight.

@Test
public void addByteEncoderWhenNoRight() throws Exception {
    channel.pipeline().addLast(NettyPipeline.HttpCodec, new ChannelHandlerAdapter() {
    });
    ChannelHandler encoder = new LineBasedFrameDecoder(12);
    testContext.addHandlerFirst("encoder", encoder);
    assertEquals(channel.pipeline().names(), Arrays.asList(NettyPipeline.HttpCodec, "encoder", "DefaultChannelPipeline$TailContext#0"));
}
Also used : ChannelHandlerAdapter(io.netty.channel.ChannelHandlerAdapter) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) ChannelHandler(io.netty.channel.ChannelHandler) Test(org.junit.Test)

Aggregations

ChannelHandler (io.netty.channel.ChannelHandler)186 Test (org.junit.Test)88 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)44 Channel (io.netty.channel.Channel)26 ChannelPipeline (io.netty.channel.ChannelPipeline)25 SslHandler (io.netty.handler.ssl.SslHandler)25 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)22 FilterChainMatchingHandler (io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler)20 ChannelFuture (io.netty.channel.ChannelFuture)20 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)20 FilterChainSelector (io.grpc.xds.FilterChainMatchingProtocolNegotiators.FilterChainMatchingHandler.FilterChainSelector)19 ChannelHandlerAdapter (io.netty.channel.ChannelHandlerAdapter)18 DownstreamTlsContext (io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext)17 FilterChain (io.grpc.xds.EnvoyServerProtoData.FilterChain)17 InetSocketAddress (java.net.InetSocketAddress)16 Test (org.junit.jupiter.api.Test)16 LineBasedFrameDecoder (io.netty.handler.codec.LineBasedFrameDecoder)12 AtomicReference (java.util.concurrent.atomic.AtomicReference)12 Bootstrap (io.netty.bootstrap.Bootstrap)11 ArrayList (java.util.ArrayList)11