@Test public void firstResolvedServerConnectedThenDisconnected() throws Exception { final SocketAddress addr1 = new SocketAddress() { @Override public String toString() { return "addr1"; } }; final SocketAddress addr2 = new SocketAddress() { @Override public String toString() { return "addr2"; } }; final ResolvedServerInfo server1 = new ResolvedServerInfo(addr1, Attributes.EMPTY); final ResolvedServerInfo server2 = new ResolvedServerInfo(addr2, Attributes.EMPTY); final ManagedClientTransport transport1 = mock(ManagedClientTransport.class); final ManagedClientTransport transport2 = mock(ManagedClientTransport.class); when(transport1.newStream(any(MethodDescriptor.class), any(Metadata.class))) .thenReturn(mock(ClientStream.class)); when(transport2.newStream(any(MethodDescriptor.class), any(Metadata.class))) .thenReturn(mock(ClientStream.class)); when(mockTransportFactory.newClientTransport(same(addr1), any(String.class))) .thenReturn(transport1, transport2); FakeNameResolverFactory nameResolverFactory = new FakeNameResolverFactory(Arrays.asList(server1, server2)); ManagedChannel channel = createChannel(nameResolverFactory, NO_INTERCEPTOR); ClientCall<String, Integer> call = channel.newCall(method, CallOptions.DEFAULT); Metadata headers = new Metadata(); call.start(mockCallListener, headers); verify(mockTransportFactory, timeout(1000)).newClientTransport(same(addr1), any(String.class)); verify(transport1, timeout(1000)).start(transportListenerCaptor.capture()); transportListenerCaptor.getValue().transportReady(); verify(transport1, timeout(1000)).newStream(same(method), same(headers)); transportListenerCaptor.getValue().transportShutdown(Status.UNAVAILABLE); ClientCall<String, Integer> call2 = channel.newCall(method, CallOptions.DEFAULT); call2.start(mockCallListener, headers); verify(transport2, timeout(1000)).start(transportListenerCaptor.capture()); verify(mockTransportFactory, times(2)).newClientTransport(same(addr1), any(String.class)); transportListenerCaptor.getValue().transportReady(); verify(transport2, timeout(1000)).newStream(same(method), same(headers)); }
@Override public <ReqT, RespT> ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions) { return interceptorChannel.newCall(method, callOptions); }
ManagedChannelImpl extends ManagedChannel implements WithLogId { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions) { return interceptorChannel.newCall(method, callOptions); } }
ManagedChannelImpl extends ManagedChannel implements WithLogId { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions) { return interceptorChannel.newCall(method, callOptions); } ManagedChannelImpl(String target, BackoffPolicy.Provider backoffPolicyProvider,
      NameResolver.Factory nameResolverFactory, Attributes nameResolverParams,
      LoadBalancer.Factory loadBalancerFactory, ClientTransportFactory transportFactory,
      DecompressorRegistry decompressorRegistry, CompressorRegistry compressorRegistry,
      @Nullable Executor executor, @Nullable String userAgent,
      List<ClientInterceptor> interceptors); }
ManagedChannelImpl extends ManagedChannel implements WithLogId { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions) { return interceptorChannel.newCall(method, callOptions); } ManagedChannelImpl(String target, BackoffPolicy.Provider backoffPolicyProvider,
      NameResolver.Factory nameResolverFactory, Attributes nameResolverParams,
      LoadBalancer.Factory loadBalancerFactory, ClientTransportFactory transportFactory,
      DecompressorRegistry decompressorRegistry, CompressorRegistry compressorRegistry,
      @Nullable Executor executor, @Nullable String userAgent,
      List<ClientInterceptor> interceptors); @Override ManagedChannelImpl shutdown(); @Override ManagedChannelImpl shutdownNow(); @Override boolean isShutdown(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override boolean isTerminated(); @Override ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method,
      CallOptions callOptions); @Override String authority(); @Override String getLogId(); }
ManagedChannelImpl extends ManagedChannel implements WithLogId { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method, CallOptions callOptions) { return interceptorChannel.newCall(method, callOptions); } ManagedChannelImpl(String target, BackoffPolicy.Provider backoffPolicyProvider,
      NameResolver.Factory nameResolverFactory, Attributes nameResolverParams,
      LoadBalancer.Factory loadBalancerFactory, ClientTransportFactory transportFactory,
      DecompressorRegistry decompressorRegistry, CompressorRegistry compressorRegistry,
      @Nullable Executor executor, @Nullable String userAgent,
      List<ClientInterceptor> interceptors); @Override ManagedChannelImpl shutdown(); @Override ManagedChannelImpl shutdownNow(); @Override boolean isShutdown(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override boolean isTerminated(); @Override ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method,
      CallOptions callOptions); @Override String authority(); @Override String getLogId();  }