@Test public void examineInboundHeaders() { final List<Metadata> examinedHeaders = new ArrayList<Metadata>(); ClientInterceptor interceptor = new ClientInterceptor() { @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) { ClientCall<ReqT, RespT> call = next.newCall(method, callOptions); return new SimpleForwardingClientCall<ReqT, RespT>(call) { @Override public void start(ClientCall.Listener<RespT> responseListener, Metadata headers) { super.start(new SimpleForwardingClientCallListener<RespT>(responseListener) { @Override public void onHeaders(Metadata headers) { examinedHeaders.add(headers); super.onHeaders(headers); } }, headers); } }; } }; Channel intercepted = ClientInterceptors.intercept(channel, interceptor); @SuppressWarnings("unchecked") ClientCall.Listener<Integer> listener = mock(ClientCall.Listener.class); ClientCall<String, Integer> interceptedCall = intercepted.newCall(method, CallOptions.DEFAULT); interceptedCall.start(listener, new Metadata()); ArgumentCaptor<ClientCall.Listener<Integer>> captor = ArgumentCaptor.forClass(null); verify(call).start(captor.capture(), Mockito.<Metadata>any()); Metadata inboundHeaders = new Metadata(); captor.getValue().onHeaders(inboundHeaders); assertEquals(Arrays.asList(inboundHeaders), examinedHeaders); }
public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); static Channel interceptForward(Channel channel, ClientInterceptor... interceptors); static Channel interceptForward(Channel channel,
                                         List<? extends ClientInterceptor> interceptors); static Channel intercept(Channel channel, ClientInterceptor... interceptors); static Channel intercept(Channel channel, List<? extends ClientInterceptor> interceptors); }
ClientInterceptors { public static Channel intercept(Channel channel, ClientInterceptor... interceptors) { return intercept(channel, Arrays.asList(interceptors)); } private  ClientInterceptors(); static Channel interceptForward(Channel channel, ClientInterceptor... interceptors); static Channel interceptForward(Channel channel,
                                         List<? extends ClientInterceptor> interceptors); static Channel intercept(Channel channel, ClientInterceptor... interceptors); static Channel intercept(Channel channel, List<? extends ClientInterceptor> interceptors);  }