NettyChannelBuilder extends AbstractManagedChannelImplBuilder<NettyChannelBuilder> { public final NettyChannelBuilder sslContext(SslContext sslContext) { checkArgument(sslContext == null || sslContext.isClient(), "Server SSL context can not be used for client channel"); this.sslContext = sslContext; return this; } protected  NettyChannelBuilder(String host, int port); protected  NettyChannelBuilder(String target); protected  NettyChannelBuilder(SocketAddress address); static NettyChannelBuilder forAddress(SocketAddress serverAddress); static NettyChannelBuilder forAddress(String host, int port); static NettyChannelBuilder forTarget(String target); final NettyChannelBuilder channelType(Class<? extends Channel> channelType); final NettyChannelBuilder negotiationType(NegotiationType type); @Internal final NettyChannelBuilder protocolNegotiator(
          @Nullable ProtocolNegotiator protocolNegotiator); final NettyChannelBuilder eventLoopGroup(@Nullable EventLoopGroup eventLoopGroup); final NettyChannelBuilder sslContext(SslContext sslContext); final NettyChannelBuilder flowControlWindow(int flowControlWindow); final NettyChannelBuilder maxMessageSize(int maxMessageSize); final NettyChannelBuilder maxHeaderListSize(int maxHeaderListSize); @Override final NettyChannelBuilder usePlaintext(boolean skipNegotiation); static final int DEFAULT_FLOW_CONTROL_WINDOW; }
@Test public void sslContextCanBeNull() { NettyChannelBuilder builder = new NettyChannelBuilder(new SocketAddress(){}); builder.sslContext(null); }
@Test public void failIfSslContextIsNotClient() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Server SSL context can not be used for client channel"); SslContext sslContext = mock(SslContext.class); NettyChannelBuilder builder = new NettyChannelBuilder(new SocketAddress(){}); builder.sslContext(sslContext); }