You can override the onSubscribe, onNext, onError, onComplete, request and cancel methods but not the others (this is by design).
The TestSubscriber implements Disposable for convenience where dispose calls cancel.
When calling the default request method, you are requesting on behalf of the wrapped actual subscriber.
| 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 QueueSubscription | |
| private final AtomicReference | upstream
Holds the current subscription if any. |
| Access | Constructor and Description |
|---|---|
| public | TestSubscriber()
Constructs a non-forwarding TestSubscriber with an initial request value of Long.MAX_VALUE. |
| public | TestSubscriber(long
the initial request value initialRequest)Constructs a non-forwarding TestSubscriber with the specified initial request value. |
| public | TestSubscriber(Subscriber<? super T>
the actual Subscriber to forward events to downstream)Constructs a forwarding TestSubscriber but leaves the requesting to the wrapped subscriber. |
| public | TestSubscriber(Subscriber<? super T>
the actual Subscriber to forward events to actual, long the initial request value initialRequest)Constructs a forwarding TestSubscriber with the specified initial request value. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv final TestSubscriber | |
| pack-priv final TestSubscriber | Returns: thisthe expected mode mode)Asserts that the given fusion mode has been established Package-private: avoid leaking the now internal fusion properties into the public API. |
| pack-priv final TestSubscriber | |
| public final TestSubscriber | Returns: thisImplements abstract io. |
| public final TestSubscriber | Returns: thisthe check consumer to run check)Run a check consumer with this TestSubscriber instance. |
| public final TestSubscriber | Returns: thisImplements abstract io. |
| public final void | cancel()
Implements org. Publisher to stop sending data and clean up resources.
|
| public static < the value type T> TestSubscriber | Returns: the new TestSubscriber instance.Creates a TestSubscriber with Long.MAX_VALUE initial request. |
| public static < the value type T> TestSubscriber | Returns: the new TestSubscriber instance.the initial requested amount initialRequested)Creates a TestSubscriber with the given initial request. |
| public static < the value type received T> TestSubscriber | Returns: the new TestObserver instancethe actual Subscriber to forward events to delegate)Constructs a forwarding TestSubscriber. |
| public final void | dispose()
Implements io. |
| pack-priv static String | |
| public final boolean | Returns: true if this TestSubscriber received a subscriptionReturns true if this TestSubscriber received a subscription. |
| public final boolean | Returns: true if this TestSubscriber has been cancelledReturns true if this TestSubscriber has been cancelled. |
| public final boolean | isDisposed()
Implements io. |
| public void | |
| public void | onError(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(Subscription
the s)Subscription that allows requesting data via Subscription#request(long)Implements io. onNext(Object) is established before
calling Subscription#request(long).
|
| 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 | |
| pack-priv final TestSubscriber | Returns: thisthe mode to establish, see the mode)QueueSubscription constantsSets the initial fusion mode if the upstream supports fusion. |
| 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. | |
| qs | back to summary |
|---|---|
| private QueueSubscription<T> qs | |
| 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 with an initial request value of Long.MAX_VALUE. | |
| TestSubscriber | back to summary |
|---|---|
| public TestSubscriber(long initialRequest) Constructs a non-forwarding TestSubscriber with the specified initial request value. The TestSubscriber doesn't validate the initialRequest value so one can test sources with invalid values as well.
| |
| TestSubscriber | back to summary |
|---|---|
| public TestSubscriber(Subscriber<? super T> downstream) Constructs a forwarding TestSubscriber but leaves the requesting to the wrapped subscriber.
| |
| TestSubscriber | back to summary |
|---|---|
| public TestSubscriber(Subscriber<? super T> actual, long initialRequest) Constructs a forwarding TestSubscriber with the specified initial request value. The TestSubscriber doesn't validate the initialRequest value so one can test sources with invalid values as well.
| |
| assertFuseable | back to summary |
|---|---|
| pack-priv final TestSubscriber Assert that the upstream is a fuseable source. Package-private: avoid leaking the now internal fusion properties into the public API. Use SubscriberFusion to work with such tests.
| |
| assertFusionMode | back to summary |
|---|---|
| pack-priv final TestSubscriber Asserts that the given fusion mode has been established Package-private: avoid leaking the now internal fusion properties into the public API. Use SubscriberFusion to work with such tests.
| |
| assertNotFuseable | back to summary |
|---|---|
| pack-priv final TestSubscriber Assert that the upstream is not a fuseable source. Package-private: avoid leaking the now internal fusion properties into the public API. Use SubscriberFusion to work with such tests.
| |
| assertNotSubscribed | back to summary |
|---|---|
| public final TestSubscriber Implements abstract io. Assert that the onSubscribe method hasn't been called at all.
| |
| assertOf | back to summary |
|---|---|
| public final TestSubscriber Run a check consumer with this TestSubscriber instance.
| |
| assertSubscribed | back to summary |
|---|---|
| public final TestSubscriber Implements abstract io. Assert that the onSubscribe method was called exactly once.
| |
| 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> TestSubscriber Creates a TestSubscriber with Long.MAX_VALUE initial request.
| |
| create | back to summary |
|---|---|
| public static <T> TestSubscriber Creates a TestSubscriber with the given initial request.
| |
| create | back to summary |
|---|---|
| public static <T> TestSubscriber Constructs a forwarding TestSubscriber.
| |
| dispose | back to summary |
|---|---|
| public final void dispose() Implements io. Doc from io. Dispose the resource, the operation should be idempotent.
| |
| fusionModeToString | back to summary |
|---|---|
| pack-priv static String fusionModeToString(int mode) | |
| hasSubscription | back to summary |
|---|---|
| public final boolean hasSubscription() Returns true if this TestSubscriber received a subscription.
| |
| isCancelled | back to summary |
|---|---|
| public final boolean isCancelled() Returns true if this TestSubscriber has been cancelled.
| |
| isDisposed | back to summary |
|---|---|
| public final boolean isDisposed() Implements io. Doc from io. Returns true if this resource has been 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(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(Subscription s) Implements io. Doc from io. Implementors of this method should make sure everything that needs
to be visible in
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
| |
| setInitialFusionMode | back to summary |
|---|---|
| pack-priv final TestSubscriber Sets the initial fusion mode if the upstream supports fusion. Package-private: avoid leaking the now internal fusion properties into the public API. Use SubscriberFusion to work with such tests.
| |
| 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 io. onNext(Object) is established before
calling Subscription#request(long).
|
| 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 io. Doc from io. Implementors of this method should make sure everything that needs
to be visible in
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. | |