@Test public void tlsHandler() { Attributes eagAttributes = Attributes.EMPTY; GrpcHttp2ConnectionHandler mockHandler = mock(GrpcHttp2ConnectionHandler.class); when(mockHandler.getEagAttributes()).thenReturn(eagAttributes); Handler handler = googleProtocolNegotiator.newHandler(mockHandler); verify(altsProtocolNegotiator, never()).newHandler(mockHandler); verify(tlsProtocolNegotiator, times(1)).newHandler(mockHandler); }
@Override public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { return altsProtocolNegotiator.newHandler(grpcHandler); } else { return tlsProtocolNegotiator.newHandler(grpcHandler); } }
GoogleDefaultProtocolNegotiator implements ProtocolNegotiator { @Override public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { return altsProtocolNegotiator.newHandler(grpcHandler); } else { return tlsProtocolNegotiator.newHandler(grpcHandler); } } }
GoogleDefaultProtocolNegotiator implements ProtocolNegotiator { @Override public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { return altsProtocolNegotiator.newHandler(grpcHandler); } else { return tlsProtocolNegotiator.newHandler(grpcHandler); } } GoogleDefaultProtocolNegotiator(TsiHandshakerFactory altsFactory, SslContext sslContext); @VisibleForTesting  GoogleDefaultProtocolNegotiator(
      ProtocolNegotiator altsProtocolNegotiator, ProtocolNegotiator tlsProtocolNegotiator); }
GoogleDefaultProtocolNegotiator implements ProtocolNegotiator { @Override public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { return altsProtocolNegotiator.newHandler(grpcHandler); } else { return tlsProtocolNegotiator.newHandler(grpcHandler); } } GoogleDefaultProtocolNegotiator(TsiHandshakerFactory altsFactory, SslContext sslContext); @VisibleForTesting  GoogleDefaultProtocolNegotiator(
      ProtocolNegotiator altsProtocolNegotiator, ProtocolNegotiator tlsProtocolNegotiator); @Override Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler); @Override void close(); }
GoogleDefaultProtocolNegotiator implements ProtocolNegotiator { @Override public Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler) { if (grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_ADDR_AUTHORITY) != null || grpcHandler.getEagAttributes().get(GrpcAttributes.ATTR_LB_PROVIDED_BACKEND) != null) { return altsProtocolNegotiator.newHandler(grpcHandler); } else { return tlsProtocolNegotiator.newHandler(grpcHandler); } } GoogleDefaultProtocolNegotiator(TsiHandshakerFactory altsFactory, SslContext sslContext); @VisibleForTesting  GoogleDefaultProtocolNegotiator(
      ProtocolNegotiator altsProtocolNegotiator, ProtocolNegotiator tlsProtocolNegotiator); @Override Handler newHandler(GrpcHttp2ConnectionHandler grpcHandler); @Override void close();  }