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.Subscription
that 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 void
awaitRequestN(long amount)
Wait until thePublisherSource.Subscription.request(long)
amount exceedsamount
.void
awaitRequestNUninterruptibly(long amount)
Wait until thePublisherSource.Subscription.request(long)
amount exceedsamount
without being interrupted.void
request(long n)
Requestsn
more items from the associatedPublisherSource
for the associatedPublisherSource.Subscriber
.long
requested()
Returns the cumulative total ofn
fromrequest(long)
s.boolean
requestedEquals(long value)
Test if the cumulative value ofrequest(long)
matchesvalue
.java.lang.String
toString()
-
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.Subscription
Requestsn
more items from the associatedPublisherSource
for the associatedPublisherSource.Subscriber
.See Reactive Streams specifications for the rules about how and when this method will be invoked.
- Specified by:
request
in interfacePublisherSource.Subscription
- Parameters:
n
- Number of items to request.
-
requested
public long requested()
Returns the cumulative total ofn
fromrequest(long)
s.- Returns:
- the cumulative total of
n
fromrequest(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:
true
if the cumulative value ofrequest(long)
matchesvalue
.
-
awaitRequestN
public void awaitRequestN(long amount) throws java.lang.InterruptedException
Wait 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 exceedsamount
without being interrupted. This method catches anInterruptedException
and discards it silently.- Parameters:
amount
- the amount to wait for.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-