use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project riposte by Nike-Inc.
the class HttpChannelInitializerTest method initChannel_adds_ChannelPipelineFinalizerHandler_as_the_last_handler_and_uses_the_ExceptionHandlingHandler_handler_and_responseSender_and_metricsListener.
@Test
public void initChannel_adds_ChannelPipelineFinalizerHandler_as_the_last_handler_and_uses_the_ExceptionHandlingHandler_handler_and_responseSender_and_metricsListener() {
// given
HttpChannelInitializer hci = basicHttpChannelInitializerNoUtilityHandlers();
MetricsListener expectedMetricsListener = mock(MetricsListener.class);
Whitebox.setInternalState(hci, "metricsListener", expectedMetricsListener);
ResponseSender expectedResponseSender = extractField(hci, "responseSender");
// when
hci.initChannel(socketChannelMock);
// then
ArgumentCaptor<ChannelHandler> channelHandlerArgumentCaptor = ArgumentCaptor.forClass(ChannelHandler.class);
verify(channelPipelineMock, atLeastOnce()).addLast(anyString(), channelHandlerArgumentCaptor.capture());
List<ChannelHandler> handlers = channelHandlerArgumentCaptor.getAllValues();
Pair<Integer, ChannelPipelineFinalizerHandler> channelPipelineFinalizerHandler = findChannelHandler(handlers, ChannelPipelineFinalizerHandler.class);
assertThat(channelPipelineFinalizerHandler, notNullValue());
assertThat(channelPipelineFinalizerHandler.getLeft(), is(handlers.size() - 1));
// and then
Pair<Integer, ExceptionHandlingHandler> expectedExceptionHandlingHandlerPair = findChannelHandler(handlers, ExceptionHandlingHandler.class);
assertThat(expectedExceptionHandlingHandlerPair, notNullValue());
ExceptionHandlingHandler actualExceptionHandlingHandler = (ExceptionHandlingHandler) Whitebox.getInternalState(channelPipelineFinalizerHandler.getRight(), "exceptionHandlingHandler");
ResponseSender actualResponseSender = (ResponseSender) Whitebox.getInternalState(channelPipelineFinalizerHandler.getRight(), "responseSender");
MetricsListener actualMetricsListener = (MetricsListener) Whitebox.getInternalState(channelPipelineFinalizerHandler.getRight(), "metricsListener");
assertThat(actualExceptionHandlingHandler, is(expectedExceptionHandlingHandlerPair.getRight()));
assertThat(actualResponseSender, is(expectedResponseSender));
assertThat(actualMetricsListener, is(expectedMetricsListener));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project grpc-java by grpc.
the class ProtocolNegotiatorsTest method tlsHandler_userEventTriggeredSslEvent_supportedProtocolGrpcExp.
@Test
public void tlsHandler_userEventTriggeredSslEvent_supportedProtocolGrpcExp() throws Exception {
SslHandler goodSslHandler = new SslHandler(engine, false) {
@Override
public String applicationProtocol() {
return "grpc-exp";
}
};
ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
pipeline.addLast(handler);
pipeline.replace(SslHandler.class, null, goodSslHandler);
channelHandlerCtx = pipeline.context(handler);
Object sslEvent = SslHandshakeCompletionEvent.SUCCESS;
pipeline.fireUserEventTriggered(sslEvent);
assertTrue(channel.isOpen());
ChannelHandlerContext grpcHandlerCtx = pipeline.context(grpcHandler);
assertNotNull(grpcHandlerCtx);
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project grpc-java by grpc.
the class ProtocolNegotiatorsTest method tlsAdapter_exceptionClosesChannel.
@Test
public void tlsAdapter_exceptionClosesChannel() throws Exception {
ChannelHandler handler = new ServerTlsHandler(sslContext, grpcHandler);
// Use addFirst due to the funny error handling in EmbeddedChannel.
pipeline.addFirst(handler);
pipeline.fireExceptionCaught(new Exception("bad"));
assertFalse(channel.isOpen());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project camel by apache.
the class NettyHttpCompressTest method createRegistry.
// setup the decompress decoder here
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
decoders.add(new HttpContentDecompressor());
registry.bind("myDecoders", decoders);
return registry;
}
use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelHandler in project camel by apache.
the class NettyHttpGetWithInvalidMessageTest method createRegistry.
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry registry = super.createRegistry();
// setup the String encoder and decoder
StringDecoder stringDecoder = new StringDecoder();
registry.bind("string-decoder", stringDecoder);
StringEncoder stringEncoder = new StringEncoder();
registry.bind("string-encoder", stringEncoder);
List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
decoders.add(stringDecoder);
List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
encoders.add(stringEncoder);
registry.bind("encoders", encoders);
registry.bind("decoders", decoders);
return registry;
}
Aggregations