public final class TestSubscription extends TestCancellable implements PublisherSource.Subscription
PublisherSource.Subscription
that tracks requests and cancellation.IGNORE_CANCEL
Constructor and Description |
---|
TestSubscription() |
Modifier and Type | Method and Description |
---|---|
void |
awaitRequestN(long amount)
Wait until the
PublisherSource.Subscription.request(long) amount exceeds amount . |
void |
awaitRequestNUninterruptibly(long amount)
Wait until the
PublisherSource.Subscription.request(long) amount exceeds amount without being interrupted. |
void |
request(long n)
Requests
n more items from the associated PublisherSource for the associated
PublisherSource.Subscriber . |
long |
requested()
Returns the cumulative total of
n from request(long) s. |
boolean |
requestedEquals(long value)
Test if the cumulative value of
request(long) matches value . |
java.lang.String |
toString() |
awaitCancelled, awaitCancelledUninterruptibly, cancel, isCancelled
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
cancel
public void request(long n)
PublisherSource.Subscription
n
more items from the associated PublisherSource
for the associated
PublisherSource.Subscriber
.
See Reactive Streams specifications for the rules about how and when this method will be invoked.
request
in interface PublisherSource.Subscription
n
- Number of items to request.public long requested()
n
from request(long)
s.n
from request(long)
s.public boolean requestedEquals(long value)
request(long)
matches value
. This method will take into account
invalid values (e.g. 0
) which may otherwise be challenging to validate with requested()
.value
- The invalid value to check.true
if the cumulative value of request(long)
matches value
.public void awaitRequestN(long amount) throws java.lang.InterruptedException
PublisherSource.Subscription.request(long)
amount exceeds amount
.amount
- the amount to wait for.java.lang.InterruptedException
- If this thread is interrupted while waiting.public void awaitRequestNUninterruptibly(long amount)
PublisherSource.Subscription.request(long)
amount exceeds amount
without being interrupted. This
method catches an InterruptedException
and discards it silently.amount
- the amount to wait for.public java.lang.String toString()
toString
in class java.lang.Object