Java Code Examples for io.grpc.stub.ClientCallStreamObserver#request()
The following examples show how to use
io.grpc.stub.ClientCallStreamObserver#request() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtoReflectionServiceTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void flowControl() throws Exception { FlowControlClientResponseObserver clientResponseObserver = new FlowControlClientResponseObserver(); ClientCallStreamObserver<ServerReflectionRequest> requestObserver = (ClientCallStreamObserver<ServerReflectionRequest>) stub.serverReflectionInfo(clientResponseObserver); // ClientCalls.startCall() calls request(1) initially, so we should get an immediate response. requestObserver.onNext(flowControlRequest); assertEquals(1, clientResponseObserver.getResponses().size()); assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(0)); // Verify we don't receive an additional response until we request it. requestObserver.onNext(flowControlRequest); assertEquals(1, clientResponseObserver.getResponses().size()); requestObserver.request(1); assertEquals(2, clientResponseObserver.getResponses().size()); assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(1)); requestObserver.onCompleted(); assertTrue(clientResponseObserver.onCompleteCalled()); }
Example 2
Source File: ProtoReflectionServiceTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void flowControlOnCompleteWithPendingRequest() throws Exception { FlowControlClientResponseObserver clientResponseObserver = new FlowControlClientResponseObserver(); ClientCallStreamObserver<ServerReflectionRequest> requestObserver = (ClientCallStreamObserver<ServerReflectionRequest>) stub.serverReflectionInfo(clientResponseObserver); // ClientCalls.startCall() calls request(1) initially, so make additional request. requestObserver.onNext(flowControlRequest); requestObserver.onNext(flowControlRequest); requestObserver.onCompleted(); assertEquals(1, clientResponseObserver.getResponses().size()); assertFalse(clientResponseObserver.onCompleteCalled()); requestObserver.request(1); assertTrue(clientResponseObserver.onCompleteCalled()); assertEquals(2, clientResponseObserver.getResponses().size()); assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(1)); }
Example 3
Source File: ProtoReflectionServiceTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void flowControlOnCompleteWithPendingRequest() throws Exception { FlowControlClientResponseObserver clientResponseObserver = new FlowControlClientResponseObserver(); ClientCallStreamObserver<ServerReflectionRequest> requestObserver = (ClientCallStreamObserver<ServerReflectionRequest>) stub.serverReflectionInfo(clientResponseObserver); requestObserver.onNext(flowControlRequest); requestObserver.onCompleted(); assertEquals(0, clientResponseObserver.getResponses().size()); assertFalse(clientResponseObserver.onCompleteCalled()); requestObserver.request(1); assertTrue(clientResponseObserver.onCompleteCalled()); assertEquals(1, clientResponseObserver.getResponses().size()); assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(0)); }
Example 4
Source File: ProtoReflectionServiceTest.java From grpc-java with Apache License 2.0 | 5 votes |
@Test public void flowControl() throws Exception { FlowControlClientResponseObserver clientResponseObserver = new FlowControlClientResponseObserver(); ClientCallStreamObserver<ServerReflectionRequest> requestObserver = (ClientCallStreamObserver<ServerReflectionRequest>) stub.serverReflectionInfo(clientResponseObserver); // Verify we don't receive a response until we request it. requestObserver.onNext(flowControlRequest); assertEquals(0, clientResponseObserver.getResponses().size()); requestObserver.request(1); assertEquals(1, clientResponseObserver.getResponses().size()); assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(0)); // Verify we don't receive an additional response until we request it. requestObserver.onNext(flowControlRequest); assertEquals(1, clientResponseObserver.getResponses().size()); requestObserver.request(1); assertEquals(2, clientResponseObserver.getResponses().size()); assertEquals(flowControlGoldenResponse, clientResponseObserver.getResponses().get(1)); requestObserver.onCompleted(); assertTrue(clientResponseObserver.onCompleteCalled()); }