Package io.grpc.internal.testing
Class StreamRecorder<T>
java.lang.Object
io.grpc.internal.testing.StreamRecorder<T>
- All Implemented Interfaces:
io.grpc.stub.StreamObserver<T>
Utility implementation of
StreamObserver
used in testing. Records all the observed
values produced by the stream as well as any errors.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Throwable
private final com.google.common.util.concurrent.SettableFuture
<T> private final CountDownLatch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Waits for the stream to terminate.boolean
awaitCompletion
(int timeout, TimeUnit unit) Waits a fixed timeout for the stream to terminate.static <T> StreamRecorder
<T> create()
Creates a new recorder.com.google.common.util.concurrent.ListenableFuture
<T> Returns aListenableFuture
for the first value received from the stream.getError()
Returns the stream terminating error.Returns the current set of received values.void
void
void
-
Field Details
-
latch
-
results
-
error
-
firstValue
-
-
Constructor Details
-
StreamRecorder
private StreamRecorder()
-
-
Method Details
-
create
Creates a new recorder. -
onNext
- Specified by:
onNext
in interfaceio.grpc.stub.StreamObserver<T>
-
onError
- Specified by:
onError
in interfaceio.grpc.stub.StreamObserver<T>
-
onCompleted
public void onCompleted()- Specified by:
onCompleted
in interfaceio.grpc.stub.StreamObserver<T>
-
awaitCompletion
Waits for the stream to terminate.- Throws:
Exception
-
awaitCompletion
Waits a fixed timeout for the stream to terminate.- Throws:
Exception
-
getValues
Returns the current set of received values. -
getError
Returns the stream terminating error. -
firstValue
Returns aListenableFuture
for the first value received from the stream. Useful for testing unary call patterns.
-