Search in sources :

Example 6 with StreamingInputCallResponse

use of io.grpc.testing.integration.Messages.StreamingInputCallResponse in project grpc-java by grpc.

the class AbstractInteropTest method clientStreaming.

@Test
public void clientStreaming() throws Exception {
    final List<StreamingInputCallRequest> requests = Arrays.asList(StreamingInputCallRequest.newBuilder().setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[27182]))).build(), StreamingInputCallRequest.newBuilder().setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[8]))).build(), StreamingInputCallRequest.newBuilder().setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[1828]))).build(), StreamingInputCallRequest.newBuilder().setPayload(Payload.newBuilder().setBody(ByteString.copyFrom(new byte[45904]))).build());
    final StreamingInputCallResponse goldenResponse = StreamingInputCallResponse.newBuilder().setAggregatedPayloadSize(74922).build();
    StreamRecorder<StreamingInputCallResponse> responseObserver = StreamRecorder.create();
    StreamObserver<StreamingInputCallRequest> requestObserver = asyncStub.streamingInputCall(responseObserver);
    for (StreamingInputCallRequest request : requests) {
        requestObserver.onNext(request);
    }
    requestObserver.onCompleted();
    assertEquals(goldenResponse, responseObserver.firstValue().get());
    responseObserver.awaitCompletion();
    assertThat(responseObserver.getValues()).hasSize(1);
    Throwable t = responseObserver.getError();
    if (t != null) {
        throw new AssertionError(t);
    }
}
Also used : StreamingInputCallRequest(io.grpc.testing.integration.Messages.StreamingInputCallRequest) StreamingInputCallResponse(io.grpc.testing.integration.Messages.StreamingInputCallResponse) Test(org.junit.Test)

Aggregations

StreamingInputCallRequest (io.grpc.testing.integration.Messages.StreamingInputCallRequest)6 StreamingInputCallResponse (io.grpc.testing.integration.Messages.StreamingInputCallResponse)6 Test (org.junit.Test)5 StatusRuntimeException (io.grpc.StatusRuntimeException)3 StreamObserver (io.grpc.stub.StreamObserver)3 TestServiceImplBase (io.grpc.testing.integration.TestServiceGrpc.TestServiceImplBase)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 Status (io.grpc.Status)1 MetricsRecord (io.grpc.internal.testing.StatsTestUtils.MetricsRecord)1 ClientCallStreamObserver (io.grpc.stub.ClientCallStreamObserver)1