Subscriber implementation that records events and allows making assertions about them.
You can override the onSubscribe(Subscription), onNext(Object), onError(Throwable) and
onComplete() methods but not the others (this is by design).
When calling the default request method, you are requesting on behalf of the
wrapped actual Subscriber if any.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static enum | TestSubscriber.EmptySubscriber
A subscriber that ignores all events and does not report errors. |
| Modifier and Type | Field and Description |
|---|---|
| private volatile boolean | cancelled
Makes sure the incoming Subscriptions get cancelled immediately. |
| private final Subscriber | downstream
The actual subscriber to forward events to. |
| private final AtomicLong | missedRequested
Holds the requested amount until a subscription arrives. |
| private final AtomicReference | upstream
Holds the current subscription if any. |
| Access | Constructor and Description |
|---|---|
| public | TestSubscriber()
Constructs a non-forwarding |
| public | TestSubscriber(long
the initial request amount initialRequest)Constructs a non-forwarding |
| public | TestSubscriber(@NonNull Subscriber<? super T>
the actual downstream)Subscriber to forward events toConstructs a forwarding |
| public | TestSubscriber(@NonNull Subscriber<? super T>
the actual actual, long Subscriber to forward events tothe initial request amount initialRequest)Constructs a forwarding |
| Modifier and Type | Method and Description |
|---|---|
| protected final TestSubscriber | Returns: thisImplements abstract io. onSubscribe(Subscription) method was called exactly once.
|
| public final void | cancel()
Implements org. Publisher to stop sending data and clean up resources.
|
| public static < the value type T> @NonNull TestSubscriber | Returns: the newTestSubscriber instance.Creates a |
| public static < the value type T> @NonNull TestSubscriber | Returns: the newTestSubscriber instance.the initial requested amount initialRequested)Creates a |
| public static < the value type received T> TestSubscriber | Returns: the new TestObserver instancethe actual delegate)Subscriber to forward events toConstructs a forwarding |
| protected final void | dispose()
Implements abstract io. |
| public final boolean | hasSubscription()
Returns true if this |
| public final boolean | Returns: true if thisTestSubscriber has been cancelledReturns true if this |
| protected final boolean | isDisposed()
Implements abstract io. |
| public void | |
| public void | onError(@NonNull Throwable
the throwable signaled t)Implements org. |
| public void | onNext(T
the element signaled t)Implements org. Publisher in response to requests to Subscription#request(long).
|
| protected void | |
| public void | onSubscribe(@NonNull Subscription
the s)Subscription that allows requesting data via Subscription#request(long)Implements org. Publisher#subscribe(Subscriber).
|
| public final void | request(long
the strictly positive number of elements to requests to the upstream n)PublisherImplements org. Publisher until demand is signaled via this method.
|
| public final TestSubscriber |
| cancelled | back to summary |
|---|---|
| private volatile boolean cancelled Makes sure the incoming Subscriptions get cancelled immediately. | |
| downstream | back to summary |
|---|---|
| private final Subscriber<? super T> downstream The actual subscriber to forward events to. | |
| missedRequested | back to summary |
|---|---|
| private final AtomicLong missedRequested Holds the requested amount until a subscription arrives. | |
| upstream | back to summary |
|---|---|
| private final AtomicReference<Subscription> upstream Holds the current subscription if any. | |
| TestSubscriber | back to summary |
|---|---|
| public TestSubscriber() Constructs a non-forwarding | |
| TestSubscriber | back to summary |
|---|---|
| public TestSubscriber(long initialRequest) Constructs a non-forwarding The
| |
| TestSubscriber | back to summary |
|---|---|
| public TestSubscriber(@NonNull Subscriber<? super T> downstream) Constructs a forwarding
| |
| TestSubscriber | back to summary |
|---|---|
| public TestSubscriber(@NonNull Subscriber<? super T> actual, long initialRequest) Constructs a forwarding The
| |
| assertSubscribed | back to summary |
|---|---|
| protected final TestSubscriber Implements abstract io. Assert that the
| |
| cancel | back to summary |
|---|---|
| public final void cancel() Implements org. Doc from org. Request the Data may still be sent to meet previously signalled demand after calling cancel.
| |
| create | back to summary |
|---|---|
| public static <T> @NonNull TestSubscriber Creates a
| |
| create | back to summary |
|---|---|
| public static <T> @NonNull TestSubscriber Creates a
| |
| create | back to summary |
|---|---|
| public static <T> TestSubscriber Constructs a forwarding
| |
| dispose | back to summary |
|---|---|
| protected final void dispose() Implements abstract io. Doc from io. Cancel/dispose this test consumer.
| |
| hasSubscription | back to summary |
|---|---|
| public final boolean hasSubscription() Returns true if this
| |
| isCancelled | back to summary |
|---|---|
| public final boolean isCancelled() Returns true if this
| |
| isDisposed | back to summary |
|---|---|
| protected final boolean isDisposed() Implements abstract io. Doc from io. Returns true if this test consumer was cancelled/disposed.
| |
| onComplete | back to summary |
|---|---|
| public void onComplete() Implements org. Doc from org. Successful terminal state.
No further events will be sent even if
| |
| onError | back to summary |
|---|---|
| public void onError(@NonNull Throwable t) Implements org. Doc from org. Failed terminal state.
No further events will be sent even if | |
| onNext | back to summary |
|---|---|
| public void onNext(T t) Implements org. Doc from org. Data notification sent by the
| |
| onStart | back to summary |
|---|---|
| protected void onStart() Called after the onSubscribe is called and handled. | |
| onSubscribe | back to summary |
|---|---|
| public void onSubscribe(@NonNull Subscription s) Implements org. Doc from org. Invoked after calling
No data will start flowing until
It is the responsibility of this
The
| |
| request | back to summary |
|---|---|
| public final void request(long n) Implements org. Doc from org. No events will be sent by a
It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more,
it may be treated by the
Whatever has been requested can be sent by the
A | |
| requestMore | back to summary |
|---|---|
| public final TestSubscriber Calls History: 2.0.1 - experimental
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final TestSubscriber. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | onError(Throwable
the throwable signaled t)Implements org. |
| public void | onNext(Object
the element signaled t)Implements org. Publisher in response to requests to Subscription#request(long).
|
| public void | onSubscribe(Subscription
the s)Subscription that allows requesting data via Subscription#request(long)Implements org. Publisher#subscribe(Subscriber).
|
| public static TestSubscriber. | |
| public static TestSubscriber. |
| INSTANCE | back to summary |
|---|---|
| public static final TestSubscriber. | |
| EmptySubscriber | back to summary |
|---|---|
| private EmptySubscriber() | |
| onComplete | back to summary |
|---|---|
| public void onComplete() Implements org. Doc from org. Successful terminal state.
No further events will be sent even if
| |
| onError | back to summary |
|---|---|
| public void onError(Throwable t) Implements org. Doc from org. Failed terminal state.
No further events will be sent even if | |
| onNext | back to summary |
|---|---|
| public void onNext(Object t) Implements org. Doc from org. Data notification sent by the | |
| onSubscribe | back to summary |
|---|---|
| public void onSubscribe(Subscription s) Implements org. Doc from org. Invoked after calling
No data will start flowing until
It is the responsibility of this
The
| |
| valueOf | back to summary |
|---|---|
| public static TestSubscriber. | |
| values | back to summary |
|---|---|
| public static TestSubscriber. | |