Package io.servicetalk.concurrent.api
Class TestSubscription
- java.lang.Object
-
- io.servicetalk.concurrent.api.TestCancellable
-
- io.servicetalk.concurrent.api.TestSubscription
-
- All Implemented Interfaces:
Cancellable,PublisherSource.Subscription
public final class TestSubscription extends TestCancellable implements PublisherSource.Subscription
APublisherSource.Subscriptionthat tracks requests and cancellation.
-
-
Field Summary
-
Fields inherited from interface io.servicetalk.concurrent.Cancellable
IGNORE_CANCEL
-
-
Constructor Summary
Constructors Constructor Description TestSubscription()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitRequestN(long amount)Wait until thePublisherSource.Subscription.request(long)amount exceedsamount.voidawaitRequestNUninterruptibly(long amount)Wait until thePublisherSource.Subscription.request(long)amount exceedsamountwithout being interrupted.voidrequest(long n)Requestsnmore items from the associatedPublisherSourcefor the associatedPublisherSource.Subscriber.longrequested()Returns the cumulative total ofnfromrequest(long)s.booleanrequestedEquals(long value)Test if the cumulative value ofrequest(long)matchesvalue.java.lang.StringtoString()-
Methods inherited from class io.servicetalk.concurrent.api.TestCancellable
awaitCancelled, awaitCancelledUninterruptibly, cancel, isCancelled
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.servicetalk.concurrent.Cancellable
cancel
-
-
-
-
Method Detail
-
request
public void request(long n)
Description copied from interface:PublisherSource.SubscriptionRequestsnmore items from the associatedPublisherSourcefor the associatedPublisherSource.Subscriber.See Reactive Streams specifications for the rules about how and when this method will be invoked.
- Specified by:
requestin interfacePublisherSource.Subscription- Parameters:
n- Number of items to request.
-
requested
public long requested()
Returns the cumulative total ofnfromrequest(long)s.- Returns:
- the cumulative total of
nfromrequest(long)s.
-
requestedEquals
public boolean requestedEquals(long value)
Test if the cumulative value ofrequest(long)matchesvalue. This method will take into account invalid values (e.g.0) which may otherwise be challenging to validate withrequested().- Parameters:
value- The invalid value to check.- Returns:
trueif the cumulative value ofrequest(long)matchesvalue.
-
awaitRequestN
public void awaitRequestN(long amount) throws java.lang.InterruptedExceptionWait until thePublisherSource.Subscription.request(long)amount exceedsamount.- Parameters:
amount- the amount to wait for.- Throws:
java.lang.InterruptedException- If this thread is interrupted while waiting.
-
awaitRequestNUninterruptibly
public void awaitRequestNUninterruptibly(long amount)
Wait until thePublisherSource.Subscription.request(long)amount exceedsamountwithout being interrupted. This method catches anInterruptedExceptionand discards it silently.- Parameters:
amount- the amount to wait for.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-