Java Code Examples for io.netty.channel.ChannelPipeline#first()

The following examples show how to use io.netty.channel.ChannelPipeline#first() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SslServerInitializerTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_swappedInitializerWithSslHandler() throws Exception {
  SelfSignedCaCertificate ssc = SelfSignedCaCertificate.create(SSL_HOST);
  SslServerInitializer<EmbeddedChannel> sslServerInitializer =
      new SslServerInitializer<>(
          true,
          false,
          sslProvider,
          Suppliers.ofInstance(ssc.key()),
          Suppliers.ofInstance(ImmutableList.of(ssc.cert())));
  EmbeddedChannel channel = new EmbeddedChannel();
  ChannelPipeline pipeline = channel.pipeline();
  pipeline.addLast(sslServerInitializer);
  ChannelHandler firstHandler = pipeline.first();
  assertThat(firstHandler.getClass()).isEqualTo(SslHandler.class);
  SslHandler sslHandler = (SslHandler) firstHandler;
  assertThat(sslHandler.engine().getNeedClientAuth()).isTrue();
  assertThat(channel.isActive()).isTrue();
}
 
Example 2
Source File: SslClientInitializerTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void testSuccess_swappedInitializerWithSslHandler() throws Exception {
  SslClientInitializer<EmbeddedChannel> sslClientInitializer =
      new SslClientInitializer<>(
          sslProvider, hostProvider, portProvider, ImmutableList.of(), null, null);
  EmbeddedChannel channel = new EmbeddedChannel();
  ChannelPipeline pipeline = channel.pipeline();
  pipeline.addLast(sslClientInitializer);
  ChannelHandler firstHandler = pipeline.first();
  assertThat(firstHandler.getClass()).isEqualTo(SslHandler.class);
  SslHandler sslHandler = (SslHandler) firstHandler;
  assertThat(sslHandler.engine().getPeerHost()).isEqualTo(SSL_HOST);
  assertThat(sslHandler.engine().getPeerPort()).isEqualTo(SSL_PORT);
  assertThat(channel.isActive()).isTrue();
}
 
Example 3
Source File: HttpBlobStore.java    From bazel-buildfarm with Apache License 2.0 4 votes vote down vote up
private boolean isChannelPipelineEmpty(ChannelPipeline pipeline) {
  return (pipeline.first() == null)
      || (useTls
          && "ssl-handler".equals(pipeline.firstContext().name())
          && pipeline.first() == pipeline.last());
}
 
Example 4
Source File: HttpCacheClient.java    From bazel with Apache License 2.0 4 votes vote down vote up
private boolean isChannelPipelineEmpty(ChannelPipeline pipeline) {
  return (pipeline.first() == null)
      || (useTls
          && "ssl-handler".equals(pipeline.firstContext().name())
          && pipeline.first() == pipeline.last());
}