### Question:
ProtocolNegotiators { public static ProtocolNegotiator tls(SslContext sslContext) { return new TlsNegotiator(sslContext); } private  ProtocolNegotiators(); static ProtocolNegotiator serverPlaintext(); static ProtocolNegotiator serverTls(final SslContext sslContext); static ProtocolNegotiator httpProxy(final SocketAddress proxyAddress,
      final @Nullable String proxyUsername, final @Nullable String proxyPassword,
      final ProtocolNegotiator negotiator); static ProtocolNegotiator tls(SslContext sslContext); static ProtocolNegotiator plaintextUpgrade(); static ProtocolNegotiator plaintext();  }### Answer:
@Test public void tls_failsOnNullSslContext() { thrown.expect(NullPointerException.class); Object unused = ProtocolNegotiators.tls(null); }
@Test public void tls_hostAndPort() throws SSLException { SslContext ctx = GrpcSslContexts.forClient().build(); TlsNegotiator negotiator = (TlsNegotiator) ProtocolNegotiators.tls(ctx); HostPort hostPort = negotiator.parseAuthority("authority:1234"); assertEquals("authority", hostPort.host); assertEquals(1234, hostPort.port); }
@Test public void tls_host() throws SSLException { SslContext ctx = GrpcSslContexts.forClient().build(); TlsNegotiator negotiator = (TlsNegotiator) ProtocolNegotiators.tls(ctx); HostPort hostPort = negotiator.parseAuthority("[::1]"); assertEquals("[::1]", hostPort.host); assertEquals(-1, hostPort.port); }
@Test public void tls_invalidHost() throws SSLException { SslContext ctx = GrpcSslContexts.forClient().build(); TlsNegotiator negotiator = (TlsNegotiator) ProtocolNegotiators.tls(ctx); HostPort hostPort = negotiator.parseAuthority("bad_host:1234"); assertEquals("bad_host:1234", hostPort.host); assertEquals(-1, hostPort.port); }