Class StreamRecorder<T>
- java.lang.Object
-
- io.grpc.testing.StreamRecorder<T>
-
- All Implemented Interfaces:
StreamObserver<T>
@Deprecated @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1791") public class StreamRecorder<T> extends Object implements StreamObserver<T>
Deprecated.Not for public useUtility implementation ofStreamObserverused in testing. Records all the observed values produced by the stream as well as any errors.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidawaitCompletion()Deprecated.Waits for the stream to terminate.booleanawaitCompletion(int timeout, TimeUnit unit)Deprecated.Waits a fixed timeout for the stream to terminate.static <T> StreamRecorder<T>create()Deprecated.Creates a new recorder.com.google.common.util.concurrent.ListenableFuture<T>firstValue()Deprecated.Returns aListenableFuturefor the first value received from the stream.ThrowablegetError()Deprecated.Returns the stream terminating error.List<T>getValues()Deprecated.Returns the current set of received values.voidonCompleted()Deprecated.Receives a notification of successful stream completion.voidonError(Throwable t)Deprecated.Receives a terminating error from the stream.voidonNext(T value)Deprecated.Receives a value from the stream.
-
-
-
Method Detail
-
create
public static <T> StreamRecorder<T> create()
Deprecated.Creates a new recorder.
-
onNext
public void onNext(T value)
Deprecated.Description copied from interface:StreamObserverReceives a value from the stream.Can be called many times but is never called after
StreamObserver.onError(Throwable)orStreamObserver.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.- Specified by:
onNextin interfaceStreamObserver<T>- Parameters:
value- the value passed to the stream
-
onError
public void onError(Throwable t)
Deprecated.Description copied from interface:StreamObserverReceives a terminating error from the stream.May 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
onErrorno further calls to any method are allowed.tshould be aStatusExceptionorStatusRuntimeException, but otherThrowabletypes are possible. Callers should generally convert from aStatusviaStatus.asException()orStatus.asRuntimeException(). Implementations should generally convert to aStatusviaStatus.fromThrowable(Throwable).- Specified by:
onErrorin interfaceStreamObserver<T>- Parameters:
t- the error occurred on the stream
-
onCompleted
public void onCompleted()
Deprecated.Description copied from interface:StreamObserverReceives a notification of successful stream completion.May 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
onCompletedno further calls to any method are allowed.- Specified by:
onCompletedin interfaceStreamObserver<T>
-
awaitCompletion
public void awaitCompletion() throws ExceptionDeprecated.Waits for the stream to terminate.- Throws:
Exception
-
awaitCompletion
public boolean awaitCompletion(int timeout, TimeUnit unit) throws ExceptionDeprecated.Waits a fixed timeout for the stream to terminate.- Throws:
Exception
-
firstValue
public com.google.common.util.concurrent.ListenableFuture<T> firstValue()
Deprecated.Returns aListenableFuturefor the first value received from the stream. Useful for testing unary call patterns.
-
-