Class TestSubscriber.ManualProbe<I>
- All Implemented Interfaces:
org.reactivestreams.Subscriber<I>
- Direct Known Subclasses:
TestSubscriber.Probe
- Enclosing class:
- TestSubscriber
Subscriber that allows various assertions.
All timeouts are dilated automatically, for more details about time dilation refer to pekko.testkit.TestKit.
-
Method Summary
Modifier and TypeMethodDescriptionFluent DSLExpect and return the signalledThrowable.expectError(Throwable cause) Fluent DSLExpect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).expectEvent(Duration max) JAVA APIFluent DSLexpectEvent(scala.concurrent.duration.FiniteDuration max) Expect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).<T> TexpectEventPF(scala.PartialFunction<TestSubscriber.SubscriberEvent, T> f) <T> TexpectEventWithTimeoutPF(Duration max, scala.PartialFunction<TestSubscriber.SubscriberEvent, T> f) JAVA API<T> TexpectEventWithTimeoutPF(scala.concurrent.duration.Duration max, scala.PartialFunction<TestSubscriber.SubscriberEvent, T> f) Expect and return a stream element.expectNext(I element) Fluent DSLexpectNext(I e1, I e2, Object... es) Fluent DSLexpectNext(I e1, I e2, scala.collection.immutable.Seq<I> es) Fluent DSLJAVA APIexpectNext(Duration d, I element) JAVA APIexpectNext(scala.concurrent.duration.FiniteDuration d) Expect and return a stream element during specified time or timeout.expectNext(scala.concurrent.duration.FiniteDuration d, I element) Fluent DSLexpectNextChainingPF(Duration max, scala.PartialFunction<Object, Object> f) JAVA APIexpectNextChainingPF(scala.concurrent.duration.Duration max, scala.PartialFunction<Object, Object> f) Expect a stream element during specified time or timeout and test it with partial function.expectNextChainingPF(scala.PartialFunction<Object, Object> f) Expect a stream element during specified time or timeout and test it with partial function.scala.collection.immutable.Seq<I>expectNextN(long n) Expect and return the nextnstream elements.expectNextN(List<I> elems) Fluent DSL Expect the given elements to be signalled in order.expectNextN(scala.collection.immutable.Seq<I> all) Fluent DSL Expect the given elements to be signalled in order.scala.util.Either<TestSubscriber.OnComplete$,I> Expect next element or stream completion - returning whichever was signalled.expectNextOrComplete(I element) Fluent DSLFluent DSLexpectNextOrError(I element, Throwable cause) Fluent DSL Expect given next element or error signal.<T> TexpectNextPF(scala.PartialFunction<Object, T> f) Expect a stream element and test it with partial function.expectNextUnordered(I e1, I e2, Object... es) Fluent DSLexpectNextUnordered(I e1, I e2, scala.collection.immutable.Seq<I> es) Fluent DSLexpectNextUnorderedN(List<I> all) JAVA APIexpectNextUnorderedN(scala.collection.immutable.Seq<I> all) Fluent DSL Expect the given elements to be signalled in any order.<T> TexpectNextWithTimeoutPF(Duration max, scala.PartialFunction<Object, T> f) JAVA API<T> TexpectNextWithTimeoutPF(scala.concurrent.duration.Duration max, scala.PartialFunction<Object, T> f) Expect a stream element and test it with partial function.Fluent DSLexpectNoMessage(Duration remaining) Java API: Assert that no message is received for the specified time.expectNoMessage(scala.concurrent.duration.FiniteDuration remaining) Fluent DSLorg.reactivestreams.SubscriptionExpect and return aSubscription.Fluent DSLexpectSubscriptionAndComplete(boolean signalDemand) Fluent DSLExpect subscription to be followed immediately by an error signal.expectSubscriptionAndError(boolean signalDemand) Expect subscription to be followed immediately by an error signal.Fluent DSLexpectSubscriptionAndError(Throwable cause, boolean signalDemand) Fluent DSLvoidvoidvoidvoidonSubscribe(org.reactivestreams.Subscription subscription) <T> List<T>receiveWhile(Duration max, Duration idle, int messages, scala.PartialFunction<TestSubscriber.SubscriberEvent, T> f) JAVA API<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.<T> scala.concurrent.duration.Duration<T> scala.concurrent.duration.Duration<T> intreceiveWithin(Duration max, int messages) JAVA APIscala.collection.immutable.Seq<I>receiveWithin(scala.concurrent.duration.FiniteDuration max, int messages) Drains a given number of messagesintJAVA APIscala.collection.immutable.Seq<I>toStrict(scala.concurrent.duration.FiniteDuration atMost) Attempt to drain the stream into a strict collection (by requestingLong.MaxValueelements).<T> TJAVA API<T> TJAVA API<T> Twithin(scala.concurrent.duration.FiniteDuration min, scala.concurrent.duration.FiniteDuration max, scala.Function0<T> f) Execute code block while bounding its execution time betweenminandmax.<T> Twithin(scala.concurrent.duration.FiniteDuration max, scala.Function0<T> f) Same as callingwithin(0 seconds, max)(f).
-
Method Details
-
expectNext
Fluent DSLExpect multiple stream elements.
-
expectNextUnordered
Fluent DSLExpect multiple stream elements in arbitrary order.
-
expectSubscription
public org.reactivestreams.Subscription expectSubscription()Expect and return aSubscription. -
expectEvent
Expect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete). -
expectEvent
Expect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete). -
expectEvent
JAVA APIExpect and return
TestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).- Since:
- 1.1.0
-
expectEvent
Fluent DSLExpect
TestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete). -
expectNext
Expect and return a stream element. -
expectNext
Expect and return a stream element during specified time or timeout. -
expectNext
JAVA APIExpect and return a stream element during specified time or timeout.
- Since:
- 1.1.0
-
expectNext
Fluent DSLExpect a stream element.
-
expectNext
public TestSubscriber.ManualProbe<I> expectNext(scala.concurrent.duration.FiniteDuration d, I element) Fluent DSLExpect a stream element during specified time or timeout.
-
expectNext
JAVA APIFluent DSL
Expect a stream element during specified time or timeout.
- Since:
- 1.1.0
-
expectNext
Fluent DSLExpect multiple stream elements.
-
expectNextUnordered
public TestSubscriber.ManualProbe<I> expectNextUnordered(I e1, I e2, scala.collection.immutable.Seq<I> es) Fluent DSLExpect multiple stream elements in arbitrary order.
-
expectNextN
Expect and return the nextnstream elements. -
expectNextN
Fluent DSL Expect the given elements to be signalled in order. -
expectNextN
Fluent DSL Expect the given elements to be signalled in order.- Since:
- 1.1.0
-
expectNextUnorderedN
Fluent DSL Expect the given elements to be signalled in any order. -
expectNextUnorderedN
JAVA APIFluent DSL Expect the given elements to be signalled in any order.
- Since:
- 1.1.0
-
expectComplete
Fluent DSLExpect completion.
-
expectError
Expect and return the signalledThrowable. -
expectError
Fluent DSLExpect given
Throwable. -
expectSubscriptionAndError
Expect subscription to be followed immediately by an error signal.By default
1demand will be signalled in order to wake up a possibly lazy upstream.See also {@link #expectSubscriptionAndError(signalDemand:Boolean)* #expectSubscriptionAndError(signalDemand: Boolean)} if no demand should be signalled.
-
expectSubscriptionAndError
Expect subscription to be followed immediately by an error signal.Depending on the
signalDemandparameter demand may be signalled immediately after obtaining the subscription in order to wake up a possibly lazy upstream. You can disable this by setting thesignalDemandparameter tofalse.See also {@link #expectSubscriptionAndError()* #expectSubscriptionAndError()}.
-
expectSubscriptionAndError
Fluent DSLExpect subscription followed by immediate stream completion.
By default
1demand will be signalled in order to wake up a possibly lazy upstream.See also {@link #expectSubscriptionAndError(cause:Throwable,signalDemand:Boolean)* #expectSubscriptionAndError(cause: Throwable, signalDemand: Boolean)} if no demand should be signalled.
-
expectSubscriptionAndError
public TestSubscriber.ManualProbe<I> expectSubscriptionAndError(Throwable cause, boolean signalDemand) Fluent DSLExpect subscription followed by immediate stream completion. By default
1demand will be signalled in order to wake up a possibly lazy upstreamSee also {@link #expectSubscriptionAndError(cause:Throwable)* #expectSubscriptionAndError(cause: Throwable)}.
-
expectSubscriptionAndComplete
Fluent DSLExpect subscription followed by immediate stream completion. By default
1demand will be signalled in order to wake up a possibly lazy upstreamSee also {@link #expectSubscriptionAndComplete(signalDemand:Boolean)* #expectSubscriptionAndComplete(signalDemand: Boolean)} if no demand should be signalled.
-
expectSubscriptionAndComplete
Fluent DSLExpect subscription followed by immediate stream completion.
Depending on the
signalDemandparameter demand may be signalled immediately after obtaining the subscription in order to wake up a possibly lazy upstream. You can disable this by setting thesignalDemandparameter tofalse.See also {@link #expectSubscriptionAndComplete()* #expectSubscriptionAndComplete}.
-
expectNextOrError
Fluent DSLExpect given next element or error signal, returning whichever was signalled.
-
expectNextOrError
Fluent DSL Expect given next element or error signal. -
expectNextOrComplete
Expect next element or stream completion - returning whichever was signalled. -
expectNextOrComplete
Fluent DSLExpect given next element or stream completion.
-
expectNoMessage
public TestSubscriber.ManualProbe<I> expectNoMessage(scala.concurrent.duration.FiniteDuration remaining) Fluent DSLAssert that no message is received for the specified time.
-
expectNoMessage
Fluent DSLAssert that no message is received for the specified time. Waits for the default period configured as
pekko.test.expect-no-message-default. That timeout is scaled using the configuration entry "pekko.test.timefactor". -
expectNoMessage
Java API: Assert that no message is received for the specified time. -
expectNextPF
Expect a stream element and test it with partial function. -
expectNextWithTimeoutPF
public <T> T expectNextWithTimeoutPF(scala.concurrent.duration.Duration max, scala.PartialFunction<Object, T> f) Expect a stream element and test it with partial function.- Parameters:
max- wait no more than max time, otherwise throw AssertionError
-
expectNextWithTimeoutPF
JAVA APIExpect a stream element and test it with partial function.
- Parameters:
max- wait no more than max time, otherwise throw AssertionError- Since:
- 1.1.0
-
expectNextChainingPF
public TestSubscriber.ManualProbe<I> expectNextChainingPF(scala.concurrent.duration.Duration max, scala.PartialFunction<Object, Object> f) Expect a stream element during specified time or timeout and test it with partial function.Allows chaining probe methods.
- Parameters:
max- wait no more than max time, otherwise throw AssertionError
-
expectNextChainingPF
public TestSubscriber.ManualProbe<I> expectNextChainingPF(Duration max, scala.PartialFunction<Object, Object> f) JAVA APIExpect a stream element during specified time or timeout and test it with partial function.
Allows chaining probe methods.
- Parameters:
max- wait no more than max time, otherwise throw AssertionError- Since:
- 1.1.0
-
expectNextChainingPF
Expect a stream element during specified time or timeout and test it with partial function.Allows chaining probe methods.
-
expectEventWithTimeoutPF
public <T> T expectEventWithTimeoutPF(scala.concurrent.duration.Duration max, scala.PartialFunction<TestSubscriber.SubscriberEvent, T> f) -
expectEventWithTimeoutPF
public <T> T expectEventWithTimeoutPF(Duration max, scala.PartialFunction<TestSubscriber.SubscriberEvent, T> f) JAVA API- Since:
- 1.1.0
-
expectEventPF
-
receiveWhile
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) Receive messages for a given duration or until one does not match a given partial function. -
receiveWhile
public <T> List<T> receiveWhile(Duration max, Duration idle, int messages, scala.PartialFunction<TestSubscriber.SubscriberEvent, T> f) JAVA APIReceive messages for a given duration or until one does not match a given partial function.
- Since:
- 1.1.0
-
receiveWhile$default$1
public <T> scala.concurrent.duration.Duration receiveWhile$default$1() -
receiveWhile$default$2
public <T> scala.concurrent.duration.Duration receiveWhile$default$2() -
receiveWhile$default$3
public <T> int receiveWhile$default$3() -
receiveWithin
public scala.collection.immutable.Seq<I> receiveWithin(scala.concurrent.duration.FiniteDuration max, int messages) Drains a given number of messages -
receiveWithin
JAVA APIDrains a given number of messages
- Since:
- 1.1.0
-
receiveWithin$default$2
public int receiveWithin$default$2() -
toStrict
Attempt to drain the stream into a strict collection (by requestingLong.MaxValueelements).'''Use with caution: Be warned that this may not be a good idea if the stream is infinite or its elements are very large!'''
-
toStrict
JAVA APIAttempt to drain the stream into a strict collection (by requesting
Long.MaxValueelements).'''Use with caution: Be warned that this may not be a good idea if the stream is infinite or its elements are very large!'''
- Since:
- 1.1.0
-
within
public <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 betweenminandmax.withinblocks 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 enclosingwithinblock.Note that the timeout is scaled using Duration.dilated, which uses the configuration entry "pekko.test.timefactor", while the min Duration is not.
val ret = within(50 millis) { test ! "ping" expectMsgClass(classOf[String]) } -
within
JAVA APIExecute code block while bounding its execution time between
minandmax.withinblocks 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 enclosingwithinblock.Note that the timeout is scaled using Duration.dilated, which uses the configuration entry "pekko.test.timefactor", while the min Duration is not.
val ret = within(Duration.ofMillis(50)) { test ! "ping" expectMsgClass(classOf[String]) }- Since:
- 1.1.0
-
within
public <T> T within(scala.concurrent.duration.FiniteDuration max, scala.Function0<T> f) Same as callingwithin(0 seconds, max)(f). -
within
JAVA APISame as calling
within(Duration.ofSeconds(0), max)(f).- Since:
- 1.1.0
-
onSubscribe
public void onSubscribe(org.reactivestreams.Subscription subscription) - Specified by:
onSubscribein interfaceorg.reactivestreams.Subscriber<I>
-
onNext
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<I>
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<I>
-
onError
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<I>
-