Class TestSubscriber.ManualProbe<I>
- java.lang.Object
-
- org.apache.pekko.stream.testkit.TestSubscriber.ManualProbe<I>
-
- All Implemented Interfaces:
org.reactivestreams.Subscriber<I>
- Direct Known Subclasses:
TestSubscriber.Probe
- Enclosing class:
- TestSubscriber
public static class TestSubscriber.ManualProbe<I> extends java.lang.Object implements org.reactivestreams.Subscriber<I>Implementation ofSubscriberthat allows various assertions.All timeouts are dilated automatically, for more details about time dilation refer to
pekko.testkit.TestKit.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TestSubscriber.ManualProbeexpectComplete()Fluent DSLjava.lang.ThrowableexpectError()Expect and return the signalledThrowable.TestSubscriber.ManualProbeexpectError(java.lang.Throwable cause)Fluent DSLTestSubscriber.SubscriberEventexpectEvent()Expect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).TestSubscriber.SubscriberEventexpectEvent(java.time.Duration max)JAVA APITestSubscriber.ManualProbeexpectEvent(TestSubscriber.SubscriberEvent event)Fluent DSLTestSubscriber.SubscriberEventexpectEvent(scala.concurrent.duration.FiniteDuration max)Expect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).<T> TexpectEventPF(scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)<T> TexpectEventWithTimeoutPF(java.time.Duration max, scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)JAVA API<T> TexpectEventWithTimeoutPF(scala.concurrent.duration.Duration max, scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)IexpectNext()Expect and return a stream element.TestSubscriber.ManualProbeexpectNext(I element)Fluent DSLTestSubscriber.ManualProbeexpectNext(I e1, I e2, java.lang.Object... es)Fluent DSLTestSubscriber.ManualProbeexpectNext(I e1, I e2, scala.collection.immutable.Seq<I> es)Fluent DSLIexpectNext(java.time.Duration d)JAVA APITestSubscriber.ManualProbeexpectNext(java.time.Duration d, I element)JAVA PAIIexpectNext(scala.concurrent.duration.FiniteDuration d)Expect and return a stream element during specified time or timeout.TestSubscriber.ManualProbeexpectNext(scala.concurrent.duration.FiniteDuration d, I element)Fluent DSLTestSubscriber.ManualProbeexpectNextChainingPF(java.time.Duration max, scala.PartialFunction<java.lang.Object,java.lang.Object> f)JAVA APITestSubscriber.ManualProbeexpectNextChainingPF(scala.concurrent.duration.Duration max, scala.PartialFunction<java.lang.Object,java.lang.Object> f)Expect a stream element during specified time or timeout and test it with partial function.TestSubscriber.ManualProbeexpectNextChainingPF(scala.PartialFunction<java.lang.Object,java.lang.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.TestSubscriber.ManualProbeexpectNextN(java.util.List<I> elems)Fluent DSL Expect the given elements to be signalled in order.TestSubscriber.ManualProbeexpectNextN(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.ManualProbeexpectNextOrComplete(I element)Fluent DSLscala.util.Either<java.lang.Throwable,I>expectNextOrError()Fluent DSLscala.util.Either<java.lang.Throwable,I>expectNextOrError(I element, java.lang.Throwable cause)Fluent DSL Expect given next element or error signal.<T> TexpectNextPF(scala.PartialFunction<java.lang.Object,T> f)Expect a stream element and test it with partial function.TestSubscriber.ManualProbeexpectNextUnordered(I e1, I e2, java.lang.Object... es)Fluent DSLTestSubscriber.ManualProbeexpectNextUnordered(I e1, I e2, scala.collection.immutable.Seq<I> es)Fluent DSLTestSubscriber.ManualProbeexpectNextUnorderedN(java.util.List<I> all)JAVA APITestSubscriber.ManualProbeexpectNextUnorderedN(scala.collection.immutable.Seq<I> all)Fluent DSL Expect the given elements to be signalled in any order.<T> TexpectNextWithTimeoutPF(java.time.Duration max, scala.PartialFunction<java.lang.Object,T> f)JAVA API<T> TexpectNextWithTimeoutPF(scala.concurrent.duration.Duration max, scala.PartialFunction<java.lang.Object,T> f)Expect a stream element and test it with partial function.TestSubscriber.ManualProbeexpectNoMessage()Fluent DSLTestSubscriber.ManualProbeexpectNoMessage(java.time.Duration remaining)Java API: Assert that no message is received for the specified time.TestSubscriber.ManualProbeexpectNoMessage(scala.concurrent.duration.FiniteDuration remaining)Fluent DSLTestSubscriber.ManualProbeexpectNoMsg()Deprecated.Use expectNoMessage instead.TestSubscriber.ManualProbeexpectNoMsg(scala.concurrent.duration.FiniteDuration remaining)Deprecated.Use expectNoMessage instead.org.reactivestreams.SubscriptionexpectSubscription()Expect and return aSubscription.TestSubscriber.ManualProbeexpectSubscriptionAndComplete()Fluent DSLTestSubscriber.ManualProbeexpectSubscriptionAndComplete(boolean signalDemand)Fluent DSLjava.lang.ThrowableexpectSubscriptionAndError()Expect subscription to be followed immediately by an error signal.java.lang.ThrowableexpectSubscriptionAndError(boolean signalDemand)Expect subscription to be followed immediately by an error signal.TestSubscriber.ManualProbeexpectSubscriptionAndError(java.lang.Throwable cause)Fluent DSLTestSubscriber.ManualProbeexpectSubscriptionAndError(java.lang.Throwable cause, boolean signalDemand)Fluent DSLvoidonComplete()voidonError(java.lang.Throwable cause)voidonNext(I element)voidonSubscribe(org.reactivestreams.Subscription subscription)<T> java.util.List<T>receiveWhile(java.time.Duration max, java.time.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.DurationreceiveWhile$default$1()<T> scala.concurrent.duration.DurationreceiveWhile$default$2()<T> intreceiveWhile$default$3()java.util.List<I>receiveWithin(java.time.Duration max, int messages)JAVA APIscala.collection.immutable.Seq<I>receiveWithin(scala.concurrent.duration.FiniteDuration max, int messages)Drains a given number of messagesintreceiveWithin$default$2()java.util.List<I>toStrict(java.time.Duration atMost)JAVA APIscala.collection.immutable.Seq<I>toStrict(scala.concurrent.duration.FiniteDuration atMost)Attempt to drain the stream into a strict collection (by requestingLong.MaxValueelements).<T> Twithin(java.time.Duration min, java.time.Duration max, Creator<T> creator)JAVA API<T> Twithin(java.time.Duration max, Creator<T> creator)JAVA 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 Detail
-
expectNext
public TestSubscriber.ManualProbe expectNext(I e1, I e2, java.lang.Object... es)
Fluent DSLExpect multiple stream elements.
-
expectNextUnordered
public TestSubscriber.ManualProbe expectNextUnordered(I e1, I e2, java.lang.Object... es)
Fluent DSLExpect multiple stream elements in arbitrary order.
-
expectSubscription
public org.reactivestreams.Subscription expectSubscription()
Expect and return aSubscription.
-
expectEvent
public TestSubscriber.SubscriberEvent expectEvent()
Expect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).
-
expectEvent
public TestSubscriber.SubscriberEvent expectEvent(scala.concurrent.duration.FiniteDuration max)
Expect and returnTestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).
-
expectEvent
public TestSubscriber.SubscriberEvent expectEvent(java.time.Duration max)
JAVA APIExpect and return
TestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).- Since:
- 1.1.0
-
expectEvent
public TestSubscriber.ManualProbe expectEvent(TestSubscriber.SubscriberEvent event)
Fluent DSLExpect
TestSubscriber.SubscriberEvent(any of:OnSubscribe,OnNext,OnErrororOnComplete).
-
expectNext
public I expectNext()
Expect and return a stream element.
-
expectNext
public I expectNext(scala.concurrent.duration.FiniteDuration d)
Expect and return a stream element during specified time or timeout.
-
expectNext
public I expectNext(java.time.Duration d)
JAVA APIExpect and return a stream element during specified time or timeout.
- Since:
- 1.1.0
-
expectNext
public TestSubscriber.ManualProbe expectNext(I element)
Fluent DSLExpect a stream element.
-
expectNext
public TestSubscriber.ManualProbe expectNext(scala.concurrent.duration.FiniteDuration d, I element)
Fluent DSLExpect a stream element during specified time or timeout.
-
expectNext
public TestSubscriber.ManualProbe expectNext(java.time.Duration d, I element)
JAVA PAIFluent DSL
Expect a stream element during specified time or timeout.
- Since:
- 1.1.0
-
expectNext
public TestSubscriber.ManualProbe expectNext(I e1, I e2, scala.collection.immutable.Seq<I> es)
Fluent DSLExpect multiple stream elements.
-
expectNextUnordered
public TestSubscriber.ManualProbe expectNextUnordered(I e1, I e2, scala.collection.immutable.Seq<I> es)
Fluent DSLExpect multiple stream elements in arbitrary order.
-
expectNextN
public scala.collection.immutable.Seq<I> expectNextN(long n)
Expect and return the nextnstream elements.
-
expectNextN
public TestSubscriber.ManualProbe expectNextN(scala.collection.immutable.Seq<I> all)
Fluent DSL Expect the given elements to be signalled in order.
-
expectNextN
public TestSubscriber.ManualProbe expectNextN(java.util.List<I> elems)
Fluent DSL Expect the given elements to be signalled in order.- Since:
- 1.1.0
-
expectNextUnorderedN
public TestSubscriber.ManualProbe expectNextUnorderedN(scala.collection.immutable.Seq<I> all)
Fluent DSL Expect the given elements to be signalled in any order.
-
expectNextUnorderedN
public TestSubscriber.ManualProbe expectNextUnorderedN(java.util.List<I> all)
JAVA APIFluent DSL Expect the given elements to be signalled in any order.
- Since:
- 1.1.0
-
expectComplete
public TestSubscriber.ManualProbe expectComplete()
Fluent DSLExpect completion.
-
expectError
public java.lang.Throwable expectError()
Expect and return the signalledThrowable.
-
expectError
public TestSubscriber.ManualProbe expectError(java.lang.Throwable cause)
Fluent DSLExpect given
Throwable.
-
expectSubscriptionAndError
public java.lang.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
public java.lang.Throwable expectSubscriptionAndError(boolean signalDemand)
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
public TestSubscriber.ManualProbe expectSubscriptionAndError(java.lang.Throwable cause)
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 expectSubscriptionAndError(java.lang.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
public TestSubscriber.ManualProbe 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
public TestSubscriber.ManualProbe expectSubscriptionAndComplete(boolean signalDemand)
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
public scala.util.Either<java.lang.Throwable,I> expectNextOrError()
Fluent DSLExpect given next element or error signal, returning whichever was signalled.
-
expectNextOrError
public scala.util.Either<java.lang.Throwable,I> expectNextOrError(I element, java.lang.Throwable cause)
Fluent DSL Expect given next element or error signal.
-
expectNextOrComplete
public scala.util.Either<TestSubscriber.OnComplete$,I> expectNextOrComplete()
Expect next element or stream completion - returning whichever was signalled.
-
expectNextOrComplete
public TestSubscriber.ManualProbe expectNextOrComplete(I element)
Fluent DSLExpect given next element or stream completion.
-
expectNoMsg
public TestSubscriber.ManualProbe expectNoMsg()
Deprecated.Use expectNoMessage instead. Since Akka 2.5.5.Fluent DSLSame as
expectNoMsg(remaining), but correctly treating the timeFactor. NOTE! Timeout value is automatically multiplied by timeFactor.
-
expectNoMsg
public TestSubscriber.ManualProbe expectNoMsg(scala.concurrent.duration.FiniteDuration remaining)
Deprecated.Use expectNoMessage instead. Since Akka 2.5.5.Fluent DSLAssert that no message is received for the specified time. NOTE! Timeout value is automatically multiplied by timeFactor.
-
expectNoMessage
public TestSubscriber.ManualProbe expectNoMessage(scala.concurrent.duration.FiniteDuration remaining)
Fluent DSLAssert that no message is received for the specified time.
-
expectNoMessage
public TestSubscriber.ManualProbe 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
public TestSubscriber.ManualProbe expectNoMessage(java.time.Duration remaining)
Java API: Assert that no message is received for the specified time.
-
expectNextPF
public <T> T expectNextPF(scala.PartialFunction<java.lang.Object,T> f)
Expect a stream element and test it with partial function.
-
expectNextWithTimeoutPF
public <T> T expectNextWithTimeoutPF(scala.concurrent.duration.Duration max, scala.PartialFunction<java.lang.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
public <T> T expectNextWithTimeoutPF(java.time.Duration max, scala.PartialFunction<java.lang.Object,T> f)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 expectNextChainingPF(scala.concurrent.duration.Duration max, scala.PartialFunction<java.lang.Object,java.lang.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 expectNextChainingPF(java.time.Duration max, scala.PartialFunction<java.lang.Object,java.lang.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
public TestSubscriber.ManualProbe expectNextChainingPF(scala.PartialFunction<java.lang.Object,java.lang.Object> f)
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(java.time.Duration max, scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)JAVA API- Since:
- 1.1.0
-
expectEventPF
public <T> T expectEventPF(scala.PartialFunction<TestSubscriber.SubscriberEvent,T> f)
-
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> java.util.List<T> receiveWhile(java.time.Duration max, java.time.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
public java.util.List<I> receiveWithin(java.time.Duration max, int messages)
JAVA APIDrains a given number of messages
- Since:
- 1.1.0
-
receiveWithin$default$2
public int receiveWithin$default$2()
-
toStrict
public scala.collection.immutable.Seq<I> toStrict(scala.concurrent.duration.FiniteDuration atMost)
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
public java.util.List<I> toStrict(java.time.Duration atMost)
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
public <T> T within(java.time.Duration min, java.time.Duration max, Creator<T> creator)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
public <T> T within(java.time.Duration max, Creator<T> creator)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
public void onNext(I element)
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<I>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<I>
-
onError
public void onError(java.lang.Throwable cause)
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<I>
-
-