@Test public void wrapChannel_handler() throws Exception { final List<byte[]> serializedReq = new ArrayList<byte[]>(); final AtomicReference<ClientCall.Listener<?>> listener = new AtomicReference<ClientCall.Listener<?>>(); Channel channel = new Channel() { @Override public <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall( MethodDescriptor<RequestT, ResponseT> methodDescriptor, CallOptions callOptions) { return new NoopClientCall<RequestT, ResponseT>() { @Override public void start(Listener<ResponseT> responseListener, Metadata headers) { listener.set(responseListener); } @Override public void sendMessage(RequestT message) { serializedReq.add((byte[]) message); } }; } @Override public String authority() { throw new UnsupportedOperationException(); } }; Channel wChannel = binlogProvider.wrapChannel(channel); ClientCall<String, Integer> clientCall = wChannel.newCall(method, CallOptions.DEFAULT); final List<Integer> observedResponse = new ArrayList<>(); clientCall.start( new NoopClientCall.NoopClientCallListener<Integer>() { @Override public void onMessage(Integer message) { observedResponse.add(message); } }, new Metadata()); String expectedRequest = "hello world"; assertThat(binlogReq).isEmpty(); assertThat(serializedReq).isEmpty(); assertEquals(0, reqMarshaller.streamInvocations); clientCall.sendMessage(expectedRequest); assertEquals(1, reqMarshaller.streamInvocations); assertEquals(0, reqMarshaller.parseInvocations); assertThat(binlogReq).hasSize(1); assertThat(serializedReq).hasSize(1); assertEquals( expectedRequest, StringMarshaller.INSTANCE.parse(new ByteArrayInputStream(binlogReq.get(0)))); assertEquals( expectedRequest, StringMarshaller.INSTANCE.parse(new ByteArrayInputStream(serializedReq.get(0)))); int expectedResponse = 12345; assertThat(binlogResp).isEmpty(); assertThat(observedResponse).isEmpty(); assertEquals(0, respMarshaller.parseInvocations); onClientMessageHelper(listener.get(), IntegerMarshaller.INSTANCE.stream(expectedResponse)); assertEquals(1, respMarshaller.parseInvocations); assertEquals(0, respMarshaller.streamInvocations); assertThat(binlogResp).hasSize(1); assertThat(observedResponse).hasSize(1); assertEquals( expectedResponse, (int) IntegerMarshaller.INSTANCE.parse(new ByteArrayInputStream(binlogResp.get(0)))); assertEquals(expectedResponse, (int) observedResponse.get(0)); }
@Override public final Channel wrapChannel(Channel channel) { return ClientInterceptors.intercept(channel, binaryLogShim); }
BinaryLogProvider extends BinaryLog { @Override public final Channel wrapChannel(Channel channel) { return ClientInterceptors.intercept(channel, binaryLogShim); } }
BinaryLogProvider extends BinaryLog { @Override public final Channel wrapChannel(Channel channel) { return ClientInterceptors.intercept(channel, binaryLogShim); }  }
BinaryLogProvider extends BinaryLog { @Override public final Channel wrapChannel(Channel channel) { return ClientInterceptors.intercept(channel, binaryLogShim); }  @Override final Channel wrapChannel(Channel channel); @Override final ServerMethodDefinition<?, ?> wrapMethodDefinition(
      ServerMethodDefinition<ReqT, RespT> oMethodDef); @Override void close(); }
BinaryLogProvider extends BinaryLog { @Override public final Channel wrapChannel(Channel channel) { return ClientInterceptors.intercept(channel, binaryLogShim); }  @Override final Channel wrapChannel(Channel channel); @Override final ServerMethodDefinition<?, ?> wrapMethodDefinition(
      ServerMethodDefinition<ReqT, RespT> oMethodDef); @Override void close(); @VisibleForTesting
  static final Marshaller<byte[]> BYTEARRAY_MARSHALLER; }