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);
}
}
Aggregations