use of io.crate.netty.channel.PipelineRegistry in project crate by crate.
the class CrateHttpsTransportTest method testPipelineConfiguration.
@Test
public void testPipelineConfiguration() throws Exception {
Settings settings = Settings.builder().put(PATH_HOME_SETTING.getKey(), "/tmp").put(SslSettings.SSL_HTTP_ENABLED.getKey(), true).put(SslSettings.SSL_TRUSTSTORE_FILEPATH.getKey(), trustStoreFile.getAbsolutePath()).put(SslSettings.SSL_TRUSTSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_FILEPATH.getKey(), keyStoreFile.getAbsolutePath()).put(SslSettings.SSL_KEYSTORE_PASSWORD.getKey(), "keystorePassword").put(SslSettings.SSL_KEYSTORE_KEY_PASSWORD.getKey(), "keystorePassword").build();
NetworkService networkService = new NetworkService(Collections.singletonList(new NetworkService.CustomNameResolver() {
@Override
public InetAddress[] resolveDefault() {
return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
}
@Override
public InetAddress[] resolveIfPossible(String value) throws IOException {
return new InetAddress[] { InetAddresses.forString("127.0.0.1") };
}
}));
PipelineRegistry pipelineRegistry = new PipelineRegistry(settings);
pipelineRegistry.setSslContextProvider(new SslContextProvider(settings));
Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, BigArrays.NON_RECYCLING_INSTANCE, mock(ThreadPool.class), NamedXContentRegistry.EMPTY, pipelineRegistry, new NettyBootstrap(), mock(NodeClient.class));
EmbeddedChannel channel = new EmbeddedChannel();
try {
transport.start();
Netty4HttpServerTransport.HttpChannelHandler httpChannelHandler = (Netty4HttpServerTransport.HttpChannelHandler) transport.configureServerChannelHandler();
httpChannelHandler.initChannel(channel);
assertThat(channel.pipeline().first(), instanceOf(SslHandler.class));
} finally {
transport.stop();
transport.close();
channel.releaseInbound();
channel.close().awaitUninterruptibly();
}
}
Aggregations