@Deprecated @ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1791") public class StreamRecorder<T> extends Object implements StreamObserver<T>
StreamObserver used in testing. Records all the observed
values produced by the stream as well as any errors.| Modifier and Type | Method and Description |
|---|---|
void |
awaitCompletion()
Deprecated.
Waits for the stream to terminate.
|
boolean |
awaitCompletion(int timeout,
TimeUnit unit)
Deprecated.
Waits a fixed timeout for the stream to terminate.
|
static <T> StreamRecorder<T> |
create()
Deprecated.
Creates a new recorder.
|
ListenableFuture<T> |
firstValue()
Deprecated.
Returns a
ListenableFuture for the first value received from the stream. |
Throwable |
getError()
Deprecated.
Returns the stream terminating error.
|
List<T> |
getValues()
Deprecated.
Returns the current set of received values.
|
void |
onCompleted()
Deprecated.
Receives a notification of successful stream completion.
|
void |
onError(Throwable t)
Deprecated.
Receives a terminating error from the stream.
|
void |
onNext(T value)
Deprecated.
Receives a value from the stream.
|
public static <T> StreamRecorder<T> create()
public void onNext(T value)
StreamObserverCan be called many times but is never called after StreamObserver.onError(Throwable) or StreamObserver.onCompleted() are called.
Unary calls must invoke onNext at most once. Clients may invoke onNext at most once for server streaming calls, but may receive many onNext callbacks. Servers may invoke onNext at most once for client streaming calls, but may receive many onNext callbacks.
If an exception is thrown by an implementation the caller is expected to terminate the
stream by calling StreamObserver.onError(Throwable) with the caught exception prior to
propagating it.
onNext in interface StreamObserver<T>value - the value passed to the streampublic void onError(Throwable t)
StreamObserverMay only be called once and if called it must be the last method called. In particular if an
exception is thrown by an implementation of onError no further calls to any method are
allowed.
t should be a StatusException or StatusRuntimeException, but other Throwable types are possible. Callers should
generally convert from a Status via Status.asException() or
Status.asRuntimeException(). Implementations should generally convert to a
Status via Status.fromThrowable(Throwable).
onError in interface StreamObserver<T>t - the error occurred on the streampublic void onCompleted()
StreamObserverMay only be called once and if called it must be the last method called. In particular if an
exception is thrown by an implementation of onCompleted no further calls to any method
are allowed.
onCompleted in interface StreamObserver<T>public void awaitCompletion()
throws Exception
Exceptionpublic boolean awaitCompletion(int timeout,
TimeUnit unit)
throws Exception
Exceptionpublic ListenableFuture<T> firstValue()
ListenableFuture for the first value received from the stream. Useful
for testing unary call patterns.