Class TestSingleSubscriber<T>
- java.lang.Object
-
- io.servicetalk.concurrent.test.internal.TestSingleSubscriber<T>
-
- Type Parameters:
T- The type of data inonSuccess(Object).
- All Implemented Interfaces:
SingleSource.Subscriber<T>
public final class TestSingleSubscriber<T> extends java.lang.Object implements SingleSource.Subscriber<T>
ASingleSource.Subscriberthat enqueues signals and provides blocking methods to consume them.
-
-
Constructor Summary
Constructors Constructor Description TestSingleSubscriber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ThrowableawaitOnError()Block until a terminal signal is received, throws ifonSuccess(Object)and returns normally ifonError(Throwable).TawaitOnSuccess()Block until a terminal signal is received, throws ifonError(Throwable)and returns normally ifonSuccess(Object).CancellableawaitSubscription()Block untilonSubscribe(Cancellable).voidonError(java.lang.Throwable t)Failed terminal state.voidonSubscribe(Cancellable cancellable)Called when the associatedSingleSourceis subscribed viaSingleSource.subscribe(Subscriber).voidonSuccess(T result)Success terminal state.java.util.function.Supplier<java.lang.Throwable>pollTerminal(long timeout, java.util.concurrent.TimeUnit unit)Block for a terminal event.
-
-
-
Method Detail
-
onSubscribe
public void onSubscribe(Cancellable cancellable)
Description copied from interface:SingleSource.SubscriberCalled when the associatedSingleSourceis subscribed viaSingleSource.subscribe(Subscriber).- Specified by:
onSubscribein interfaceSingleSource.Subscriber<T>- Parameters:
cancellable- ACancellablethat can be used to cancel the asynchronous computation for this subscriber.
-
onSuccess
public void onSuccess(@Nullable T result)Description copied from interface:SingleSource.SubscriberSuccess terminal state.No further events will be sent.
- Specified by:
onSuccessin interfaceSingleSource.Subscriber<T>- Parameters:
result- of theSingleSource.
-
onError
public void onError(java.lang.Throwable t)
Description copied from interface:SingleSource.SubscriberFailed terminal state.No further events will be sent.
- Specified by:
onErrorin interfaceSingleSource.Subscriber<T>- Parameters:
t- the throwable signaled.
-
awaitSubscription
public Cancellable awaitSubscription()
Block untilonSubscribe(Cancellable).- Returns:
- The
PublisherSource.SubscriptionfromonSubscribe(Cancellable).
-
awaitOnError
public java.lang.Throwable awaitOnError()
Block until a terminal signal is received, throws ifonSuccess(Object)and returns normally ifonError(Throwable).- Returns:
- the exception received by
onError(Throwable).
-
awaitOnSuccess
@Nullable public T awaitOnSuccess()
Block until a terminal signal is received, throws ifonError(Throwable)and returns normally ifonSuccess(Object).- Returns:
- The value delivered to
onSuccess(Object).
-
pollTerminal
@Nullable public java.util.function.Supplier<java.lang.Throwable> pollTerminal(long timeout, java.util.concurrent.TimeUnit unit)Block for a terminal event.- Parameters:
timeout- The duration of time to wait.unit- The unit of time to apply to the duration.- Returns:
nullif a the timeout expires before a terminal event is received. A non-nullSupplierthat returnsnullifonSuccess(Object), or theThrowablefromonError(Throwable).
-
-