public static class TestSubscriber.ManualProbe<I>
extends java.lang.Object
implements org.reactivestreams.Subscriber<I>
Subscriber
that allows various assertions.
All timeouts are dilated automatically, for more details about time dilation refer to TestKit
.
Constructor and Description |
---|
ManualProbe(ActorSystem system) |
Modifier and Type | Method and Description |
---|---|
TestSubscriber.ManualProbe |
expectComplete()
Fluent DSL
|
java.lang.Throwable |
expectError()
Expect and return the signalled
Throwable . |
TestSubscriber.ManualProbe |
expectError(java.lang.Throwable cause)
Fluent DSL
|
TestSubscriber.SubscriberEvent |
expectEvent()
Expect and return
TestSubscriber.SubscriberEvent (any of: OnSubscribe , OnNext , OnError or OnComplete ). |
TestSubscriber.SubscriberEvent |
expectEvent(scala.concurrent.duration.FiniteDuration max)
Expect and return
TestSubscriber.SubscriberEvent (any of: OnSubscribe , OnNext , OnError or OnComplete ). |
TestSubscriber.ManualProbe |
expectEvent(TestSubscriber.SubscriberEvent event)
Fluent DSL
|
<T> T |
expectEventPF(scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f) |
I |
expectNext()
Expect and return a stream element.
|
I |
expectNext(scala.concurrent.duration.FiniteDuration d)
Expect and return a stream element during specified time or timeout.
|
TestSubscriber.ManualProbe |
expectNext(scala.concurrent.duration.FiniteDuration d,
I element)
Fluent DSL
|
TestSubscriber.ManualProbe |
expectNext(I element)
Fluent DSL
|
TestSubscriber.ManualProbe |
expectNext(I e1,
I e2,
java.lang.Object... es)
Fluent DSL
|
TestSubscriber.ManualProbe |
expectNext(I e1,
I e2,
scala.collection.Seq<I> es)
Fluent DSL
|
TestSubscriber.ManualProbe |
expectNextChainingPF(scala.PartialFunction<java.lang.Object,java.lang.Object> f)
Expect next element and test it with partial function.
|
scala.collection.immutable.Seq<I> |
expectNextN(long n)
Expect and return the next
n stream elements. |
TestSubscriber.ManualProbe |
expectNextN(scala.collection.immutable.Seq<I> all)
Fluent DSL
Expect the given elements to be signalled in order.
|
scala.util.Either<TestSubscriber.OnComplete$,I> |
expectNextOrComplete()
Expect next element or stream completion - returning whichever was signalled.
|
TestSubscriber.ManualProbe |
expectNextOrComplete(I element)
Fluent DSL
|
scala.util.Either<java.lang.Throwable,I> |
expectNextOrError()
Fluent DSL
|
scala.util.Either<java.lang.Throwable,I> |
expectNextOrError(I element,
java.lang.Throwable cause)
Fluent DSL
Expect given next element or error signal.
|
<T> T |
expectNextPF(scala.PartialFunction<java.lang.Object,T> f) |
TestSubscriber.ManualProbe |
expectNextUnordered(I e1,
I e2,
java.lang.Object... es)
Fluent DSL
|
TestSubscriber.ManualProbe |
expectNextUnordered(I e1,
I e2,
scala.collection.Seq<I> es)
Fluent DSL
|
TestSubscriber.ManualProbe |
expectNextUnorderedN(scala.collection.immutable.Seq<I> all)
Fluent DSL
Expect the given elements to be signalled in any order.
|
TestSubscriber.ManualProbe |
expectNoMsg()
Fluent DSL
|
TestSubscriber.ManualProbe |
expectNoMsg(scala.concurrent.duration.FiniteDuration remaining)
Fluent DSL
|
org.reactivestreams.Subscription |
expectSubscription()
Expect and return a
Subscription . |
TestSubscriber.ManualProbe |
expectSubscriptionAndComplete()
Fluent DSL
|
TestSubscriber.ManualProbe |
expectSubscriptionAndComplete(boolean signalDemand)
Fluent DSL
|
java.lang.Throwable |
expectSubscriptionAndError()
Expect subscription to be followed immediatly by an error signal.
|
java.lang.Throwable |
expectSubscriptionAndError(boolean signalDemand)
Expect subscription to be followed immediatly by an error signal.
|
TestSubscriber.ManualProbe |
expectSubscriptionAndError(java.lang.Throwable cause)
Fluent DSL
|
TestSubscriber.ManualProbe |
expectSubscriptionAndError(java.lang.Throwable cause,
boolean signalDemand)
Fluent DSL
|
void |
onComplete() |
void |
onError(java.lang.Throwable cause) |
void |
onNext(I element) |
void |
onSubscribe(org.reactivestreams.Subscription subscription) |
<T> scala.collection.immutable.Seq<T> |
receiveWhile(scala.concurrent.duration.Duration max,
scala.concurrent.duration.Duration idle,
int messages,
scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)
Receive messages for a given duration or until one does not match a given partial function.
|
scala.collection.immutable.Seq<I> |
receiveWithin(scala.concurrent.duration.FiniteDuration max,
int messages)
Drains a given number of messages
|
scala.collection.immutable.Seq<I> |
toStrict(scala.concurrent.duration.FiniteDuration atMost)
Attempt to drain the stream into a strict collection (by requesting
Long.MaxValue elements). |
<T> T |
within(scala.concurrent.duration.FiniteDuration min,
scala.concurrent.duration.FiniteDuration max,
scala.Function0<T> f)
Execute code block while bounding its execution time between
min and
max . |
<T> T |
within(scala.concurrent.duration.FiniteDuration max,
scala.Function0<T> f)
Same as calling
within(0 seconds, max)(f) . |
public ManualProbe(ActorSystem system)
public TestSubscriber.ManualProbe expectNext(I e1, I e2, java.lang.Object... es)
Expect multiple stream elements.
e1
- (undocumented)e2
- (undocumented)es
- (undocumented)public TestSubscriber.ManualProbe expectNextUnordered(I e1, I e2, java.lang.Object... es)
Expect multiple stream elements in arbitrary order.
e1
- (undocumented)e2
- (undocumented)es
- (undocumented)public org.reactivestreams.Subscription expectSubscription()
Subscription
.public TestSubscriber.SubscriberEvent expectEvent()
TestSubscriber.SubscriberEvent
(any of: OnSubscribe
, OnNext
, OnError
or OnComplete
).public TestSubscriber.SubscriberEvent expectEvent(scala.concurrent.duration.FiniteDuration max)
TestSubscriber.SubscriberEvent
(any of: OnSubscribe
, OnNext
, OnError
or OnComplete
).max
- (undocumented)public TestSubscriber.ManualProbe expectEvent(TestSubscriber.SubscriberEvent event)
Expect TestSubscriber.SubscriberEvent
(any of: OnSubscribe
, OnNext
, OnError
or OnComplete
).
event
- (undocumented)public I expectNext()
public I expectNext(scala.concurrent.duration.FiniteDuration d)
d
- (undocumented)public TestSubscriber.ManualProbe expectNext(I element)
Expect a stream element.
element
- (undocumented)public TestSubscriber.ManualProbe expectNext(scala.concurrent.duration.FiniteDuration d, I element)
Expect a stream element during specified time or timeout.
d
- (undocumented)element
- (undocumented)public TestSubscriber.ManualProbe expectNext(I e1, I e2, scala.collection.Seq<I> es)
Expect multiple stream elements.
e1
- (undocumented)e2
- (undocumented)es
- (undocumented)public TestSubscriber.ManualProbe expectNextUnordered(I e1, I e2, scala.collection.Seq<I> es)
Expect multiple stream elements in arbitrary order.
e1
- (undocumented)e2
- (undocumented)es
- (undocumented)public scala.collection.immutable.Seq<I> expectNextN(long n)
n
stream elements.n
- (undocumented)public TestSubscriber.ManualProbe expectNextN(scala.collection.immutable.Seq<I> all)
all
- (undocumented)public TestSubscriber.ManualProbe expectNextUnorderedN(scala.collection.immutable.Seq<I> all)
all
- (undocumented)public TestSubscriber.ManualProbe expectComplete()
Expect completion.
public java.lang.Throwable expectError()
Throwable
.public TestSubscriber.ManualProbe expectError(java.lang.Throwable cause)
Expect given Throwable
.
cause
- (undocumented)public java.lang.Throwable expectSubscriptionAndError()
By default 1
demand will be signalled in order to wake up a possibly lazy upstream.
See also #expectSubscriptionAndError(Boolean)
if no demand should be signalled.
public java.lang.Throwable expectSubscriptionAndError(boolean signalDemand)
Depending on the signalDemand
parameter demand may be signalled immediatly after obtaining the subscription
in order to wake up a possibly lazy upstream. You can disable this by setting the signalDemand
parameter to false
.
See also expectSubscriptionAndError()
.
signalDemand
- (undocumented)public TestSubscriber.ManualProbe expectSubscriptionAndError(java.lang.Throwable cause)
Expect subscription followed by immediate stream completion.
By default 1
demand will be signalled in order to wake up a possibly lazy upstream.
See also #expectSubscriptionAndComplete(cause: Throwable, signalDemand: Boolean)
if no demand should be signalled.
cause
- (undocumented)public TestSubscriber.ManualProbe expectSubscriptionAndError(java.lang.Throwable cause, boolean signalDemand)
Expect subscription followed by immediate stream completion.
By default 1
demand will be signalled in order to wake up a possibly lazy upstream
See also #expectSubscriptionAndError(cause: Throwable)
.
cause
- (undocumented)signalDemand
- (undocumented)public TestSubscriber.ManualProbe expectSubscriptionAndComplete()
Expect subscription followed by immediate stream completion.
By default 1
demand will be signalled in order to wake up a possibly lazy upstream
See also #expectSubscriptionAndComplete(signalDemand: Boolean)
if no demand should be signalled.
public TestSubscriber.ManualProbe expectSubscriptionAndComplete(boolean signalDemand)
Expect subscription followed by immediate stream completion.
Depending on the signalDemand
parameter demand may be signalled immediatly after obtaining the subscription
in order to wake up a possibly lazy upstream. You can disable this by setting the signalDemand
parameter to false
.
See also expectSubscriptionAndComplete()
.
signalDemand
- (undocumented)public scala.util.Either<java.lang.Throwable,I> expectNextOrError()
Expect given next element or error signal, returning whichever was signalled.
public scala.util.Either<java.lang.Throwable,I> expectNextOrError(I element, java.lang.Throwable cause)
element
- (undocumented)cause
- (undocumented)public scala.util.Either<TestSubscriber.OnComplete$,I> expectNextOrComplete()
public TestSubscriber.ManualProbe expectNextOrComplete(I element)
Expect given next element or stream completion.
element
- (undocumented)public TestSubscriber.ManualProbe expectNoMsg()
Same as expectNoMsg(remaining)
, but correctly treating the timeFactor.
public TestSubscriber.ManualProbe expectNoMsg(scala.concurrent.duration.FiniteDuration remaining)
Assert that no message is received for the specified time.
remaining
- (undocumented)public <T> T expectNextPF(scala.PartialFunction<java.lang.Object,T> f)
public TestSubscriber.ManualProbe expectNextChainingPF(scala.PartialFunction<java.lang.Object,java.lang.Object> f)
Allows chaining probe methods.
f
- (undocumented)public <T> T expectEventPF(scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)
public <T> scala.collection.immutable.Seq<T> receiveWhile(scala.concurrent.duration.Duration max, scala.concurrent.duration.Duration idle, int messages, scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)
max
- (undocumented)idle
- (undocumented)messages
- (undocumented)f
- (undocumented)public scala.collection.immutable.Seq<I> receiveWithin(scala.concurrent.duration.FiniteDuration max, int messages)
max
- (undocumented)messages
- (undocumented)public scala.collection.immutable.Seq<I> toStrict(scala.concurrent.duration.FiniteDuration atMost)
Long.MaxValue
elements).
'''Use with caution: Be warned that this may not be a good idea if the stream is infinite or its elements are very large!'''
atMost
- (undocumented)public <T> T within(scala.concurrent.duration.FiniteDuration min, scala.concurrent.duration.FiniteDuration max, scala.Function0<T> f)
min
and
max
. within
blocks may be nested. All methods in this trait which
take maximum wait times are available in a version which implicitly uses
the remaining time governed by the innermost enclosing within
block.
Note that the timeout is scaled using Duration.dilated, which uses the configuration entry "akka.test.timefactor", while the min Duration is not.
val ret = within(50 millis) {
test ! "ping"
expectMsgClass(classOf[String])
}
min
- (undocumented)max
- (undocumented)f
- (undocumented)public <T> T within(scala.concurrent.duration.FiniteDuration max, scala.Function0<T> f)
within(0 seconds, max)(f)
.max
- (undocumented)f
- (undocumented)public void onSubscribe(org.reactivestreams.Subscription subscription)
onSubscribe
in interface org.reactivestreams.Subscriber<I>
public void onNext(I element)
onNext
in interface org.reactivestreams.Subscriber<I>
public void onComplete()
onComplete
in interface org.reactivestreams.Subscriber<I>
public void onError(java.lang.Throwable cause)
onError
in interface org.reactivestreams.Subscriber<I>