akka.testkit
Interface TestKitBase

All Known Subinterfaces:
JournalPerfSpec, JournalSpec, PluginSpec, SnapshotStoreSpec
All Known Implementing Classes:
AkkaSpec, DefaultTimeoutSpec, DurableMailboxSpec, ImplicitSenderSpec, JavaJournalPerfSpec, JavaJournalSpec, JavaSnapshotStoreSpec, JavaTestKitSpec, MultiNodeSpec, TestActorRefSpec, TestActorsSpec, TestFSMRefSpec, TestKit, TestProbe, TestProbeSpec, TestTimeSpec

public interface TestKitBase

Implementation trait behind the TestKit class: you may use this if inheriting from a concrete class is not possible.

Use of the trait is discouraged because of potential issues with binary backwards compatibility in the future, use at own risk.

This trait requires the concrete class mixing it in to provide an ActorSystem which is available before this traits’s constructor is run. The recommended way is this:


 class MyTest extends TestKitBase {
   implicit lazy val system = ActorSystem() // may add arguments here
   ...
 }
 


Method Summary
 void awaitAssert(scala.Function0<java.lang.Object> a, scala.concurrent.duration.Duration max, scala.concurrent.duration.Duration interval)
          Await until the given assert does not throw an exception or the timeout expires, whichever comes first.
 void awaitCond(scala.Function0<java.lang.Object> p, scala.concurrent.duration.Duration max, scala.concurrent.duration.Duration interval, java.lang.String message)
          Await until the given condition evaluates to true or the timeout expires, whichever comes first.
 void checkMissingAndUnexpected(scala.collection.Seq<java.lang.Object> missing, scala.collection.Seq<java.lang.Object> unexpected, java.lang.String missingMessage, java.lang.String unexpectedMessage)
           
 scala.concurrent.duration.Duration end()
           
<T> T
expectMsg_internal(scala.concurrent.duration.Duration max, T obj, scala.Option<java.lang.String> hint)
           
<T> T
expectMsg(scala.concurrent.duration.FiniteDuration max, java.lang.String hint, T obj)
          Receive one message from the test actor and assert that it equals the given object.
<T> T
expectMsg(scala.concurrent.duration.FiniteDuration max, T obj)
          Receive one message from the test actor and assert that it equals the given object.
<T> T
expectMsg(T obj)
          Same as expectMsg(remaining, obj), but correctly treating the timeFactor.
<T> scala.collection.immutable.Seq<T>
expectMsgAllClassOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends T>> obj)
          Receive a number of messages from the test actor matching the given number of classes and assert that for each given class one is received which is of that class (equality, not conformance).
<T> scala.collection.immutable.Seq<T>
expectMsgAllClassOf(scala.collection.Seq<java.lang.Class<? extends T>> obj)
          Same as expectMsgAllClassOf(remaining, obj...), but correctly treating the timeFactor.
<T> scala.collection.immutable.Seq<T>
expectMsgAllConformingOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends T>> obj)
          Receive a number of messages from the test actor matching the given number of classes and assert that for each given class one is received which conforms to that class (and vice versa).
<T> scala.collection.immutable.Seq<T>
expectMsgAllConformingOf(scala.collection.Seq<java.lang.Class<? extends T>> obj)
          Same as expectMsgAllConformingOf(remaining, obj...), but correctly treating the timeFactor.
<T> scala.collection.immutable.Seq<T>
expectMsgAllOf_internal(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<T> obj)
           
<T> scala.collection.immutable.Seq<T>
expectMsgAllOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<T> obj)
          Receive a number of messages from the test actor matching the given number of objects and assert that for each given object one is received which equals it and vice versa.
<T> scala.collection.immutable.Seq<T>
expectMsgAllOf(scala.collection.Seq<T> obj)
          Same as expectMsgAllOf(remaining, obj...), but correctly treating the timeFactor.
<C> C
expectMsgAnyClassOf_internal(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends C>> obj)
           
<C> C
expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends C>> obj)
          Receive one message from the test actor and assert that it conforms to one of the given classes.
<C> C
expectMsgAnyClassOf(scala.collection.Seq<java.lang.Class<? extends C>> obj)
          Same as expectMsgAnyClassOf(remaining, obj...), but correctly treating the timeFactor.
<T> T
expectMsgAnyOf_internal(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<T> obj)
           
<T> T
expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<T> obj)
          Receive one message from the test actor and assert that it equals one of the given objects.
<T> T
expectMsgAnyOf(scala.collection.Seq<T> obj)
          Same as expectMsgAnyOf(remaining, obj...), but correctly treating the timeFactor.
<C> C
expectMsgClass_internal(scala.concurrent.duration.FiniteDuration max, java.lang.Class<C> c)
           
<C> C
expectMsgClass(java.lang.Class<C> c)
          Same as expectMsgClass(remaining, c), but correctly treating the timeFactor.
<C> C
expectMsgClass(scala.concurrent.duration.FiniteDuration max, java.lang.Class<C> c)
          Receive one message from the test actor and assert that it conforms to the given class.
<T> T
expectMsgPF(scala.concurrent.duration.Duration max, java.lang.String hint, scala.PartialFunction<java.lang.Object,T> f)
          Receive one message from the test actor and assert that the given partial function accepts it.
<T> T
expectMsgType(scala.reflect.ClassTag<T> t)
          Same as expectMsgType[T](remaining), but correctly treating the timeFactor.
<T> T
expectMsgType(scala.concurrent.duration.FiniteDuration max, scala.reflect.ClassTag<T> t)
          Receive one message from the test actor and assert that it conforms to the given type (after erasure).
 void expectNoMsg_internal(scala.concurrent.duration.FiniteDuration max)
           
 void expectNoMsg()
          Same as expectNoMsg(remaining), but correctly treating the timeFactor.
 void expectNoMsg(scala.concurrent.duration.FiniteDuration max)
          Assert that no message is received for the specified time.
 Terminated expectTerminated(ActorRef target, scala.concurrent.duration.Duration max)
          Receive one message from the test actor and assert that it is the Terminated message of the given ActorRef.
 java.lang.Object fishForMessage(scala.concurrent.duration.Duration max, java.lang.String hint, scala.PartialFunction<java.lang.Object,java.lang.Object> f)
          Hybrid of expectMsgPF and receiveWhile: receive messages while the partial function matches and returns false.
 java.lang.String format(java.util.concurrent.TimeUnit u, scala.concurrent.duration.Duration d)
           
 void ignoreMsg(scala.PartialFunction<java.lang.Object,java.lang.Object> f)
          Ignore all messages in the test actor for which the given partial function returns true.
 void ignoreNoMsg()
          Stop ignoring messages in the test actor.
<T> scala.collection.immutable.Seq<T>
internalExpectMsgAllClassOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends T>> obj)
           
<T> scala.collection.immutable.Seq<T>
internalExpectMsgAllConformingOf(scala.concurrent.duration.FiniteDuration max, scala.collection.Seq<java.lang.Class<? extends T>> obj)
           
 TestActor.Message lastMessage()
           
 ActorRef lastSender()
           
 boolean lastWasNoMsg()
          if last assertion was expectNoMsg, disable timing failure upon within() block end.
 boolean msgAvailable()
          Query queue status.
 scala.concurrent.duration.FiniteDuration now()
          Obtain current time (System.nanoTime) as Duration.
 java.util.concurrent.LinkedBlockingDeque<TestActor.Message> queue()
           
 scala.collection.immutable.Seq<java.lang.Object> receiveN_internal(int n, scala.concurrent.duration.Duration max)
           
 scala.collection.immutable.Seq<java.lang.Object> receiveN(int n)
          Same as receiveN(n, remaining) but correctly taking into account Duration.timeFactor.
 scala.collection.immutable.Seq<java.lang.Object> receiveN(int n, scala.concurrent.duration.FiniteDuration max)
          Receive N messages in a row before the given deadline.
 java.lang.Object receiveOne(scala.concurrent.duration.Duration max)
          Receive one message from the internal queue of the TestActor.
<T> scala.collection.immutable.Seq<T>
receiveWhile(scala.concurrent.duration.Duration max, scala.concurrent.duration.Duration idle, int messages, scala.PartialFunction<java.lang.Object,T> f)
          Receive a series of messages until one does not match the given partial function or the idle timeout is met (disabled by default) or the overall maximum duration is elapsed.
 scala.concurrent.duration.FiniteDuration remaining()
          Obtain time remaining for execution of the innermost enclosing within block or missing that it returns the properly dilated default for this case from settings (key "akka.test.single-expect-default").
 scala.concurrent.duration.FiniteDuration remainingOr(scala.concurrent.duration.FiniteDuration duration)
          Obtain time remaining for execution of the innermost enclosing within block or missing that it returns the given duration.
 scala.concurrent.duration.FiniteDuration remainingOrDilated(scala.concurrent.duration.Duration max)
           
 void setAutoPilot(TestActor.AutoPilot pilot)
          Install an AutoPilot to drive the testActor: the AutoPilot will be run for each received message and can be used to send or forward messages, etc.
 void shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, boolean verifySystemShutdown)
          Shut down an actor system and wait for termination.
 ActorSystem system()
           
 ActorRef testActor()
          ActorRef of the test actor.
 TestKitSettings testKitSettings()
           
 ActorRef unwatch(ActorRef ref)
          Have the testActor stop watching someone (i.e.
 ActorRef watch(ActorRef ref)
          Have the testActor watch someone (i.e.
<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).
 

Method Detail

system

ActorSystem system()

testKitSettings

TestKitSettings testKitSettings()

queue

java.util.concurrent.LinkedBlockingDeque<TestActor.Message> queue()

lastMessage

TestActor.Message lastMessage()

lastSender

ActorRef lastSender()

testActor

ActorRef testActor()
ActorRef of the test actor. Access is provided to enable e.g. registration as message target.

Returns:
(undocumented)

end

scala.concurrent.duration.Duration end()

lastWasNoMsg

boolean lastWasNoMsg()
if last assertion was expectNoMsg, disable timing failure upon within() block end.

Returns:
(undocumented)

ignoreMsg

void ignoreMsg(scala.PartialFunction<java.lang.Object,java.lang.Object> f)
Ignore all messages in the test actor for which the given partial function returns true.

Parameters:
f - (undocumented)

ignoreNoMsg

void ignoreNoMsg()
Stop ignoring messages in the test actor.


watch

ActorRef watch(ActorRef ref)
Have the testActor watch someone (i.e. context.watch(...)).

Parameters:
ref - (undocumented)
Returns:
(undocumented)

unwatch

ActorRef unwatch(ActorRef ref)
Have the testActor stop watching someone (i.e. context.unwatch(...)).

Parameters:
ref - (undocumented)
Returns:
(undocumented)

setAutoPilot

void setAutoPilot(TestActor.AutoPilot pilot)
Install an AutoPilot to drive the testActor: the AutoPilot will be run for each received message and can be used to send or forward messages, etc. Each invocation must return the AutoPilot for the next round.

Parameters:
pilot - (undocumented)

now

scala.concurrent.duration.FiniteDuration now()
Obtain current time (System.nanoTime) as Duration.

Returns:
(undocumented)

remaining

scala.concurrent.duration.FiniteDuration remaining()
Obtain time remaining for execution of the innermost enclosing within block or missing that it returns the properly dilated default for this case from settings (key "akka.test.single-expect-default").

Returns:
(undocumented)

remainingOr

scala.concurrent.duration.FiniteDuration remainingOr(scala.concurrent.duration.FiniteDuration duration)
Obtain time remaining for execution of the innermost enclosing within block or missing that it returns the given duration.

Parameters:
duration - (undocumented)
Returns:
(undocumented)

remainingOrDilated

scala.concurrent.duration.FiniteDuration remainingOrDilated(scala.concurrent.duration.Duration max)

msgAvailable

boolean msgAvailable()
Query queue status.

Returns:
(undocumented)

awaitCond

void awaitCond(scala.Function0<java.lang.Object> p,
               scala.concurrent.duration.Duration max,
               scala.concurrent.duration.Duration interval,
               java.lang.String message)
Await until the given condition evaluates to true or the timeout expires, whichever comes first.

If no timeout is given, take it from the innermost enclosing within block.

Note that the timeout is scaled using Duration.dilated, which uses the configuration entry "akka.test.timefactor".

Parameters:
p - (undocumented)
max - (undocumented)
interval - (undocumented)
message - (undocumented)

awaitAssert

void awaitAssert(scala.Function0<java.lang.Object> a,
                 scala.concurrent.duration.Duration max,
                 scala.concurrent.duration.Duration interval)
Await until the given assert does not throw an exception or the timeout expires, whichever comes first. If the timeout expires the last exception is thrown.

If no timeout is given, take it from the innermost enclosing within block.

Note that the timeout is scaled using Duration.dilated, which uses the configuration entry "akka.test.timefactor".

Parameters:
a - (undocumented)
max - (undocumented)
interval - (undocumented)

within

<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. 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])
       }
 

Parameters:
min - (undocumented)
max - (undocumented)
f - (undocumented)
Returns:
(undocumented)

within

<T> T within(scala.concurrent.duration.FiniteDuration max,
             scala.Function0<T> f)
Same as calling within(0 seconds, max)(f).

Parameters:
max - (undocumented)
f - (undocumented)
Returns:
(undocumented)

expectMsg

<T> T expectMsg(T obj)
Same as expectMsg(remaining, obj), but correctly treating the timeFactor.

Parameters:
obj - (undocumented)
Returns:
(undocumented)

expectMsg

<T> T expectMsg(scala.concurrent.duration.FiniteDuration max,
                T obj)
Receive one message from the test actor and assert that it equals the given object. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
max - (undocumented)
obj - (undocumented)
Returns:
the received object

expectMsg

<T> T expectMsg(scala.concurrent.duration.FiniteDuration max,
                java.lang.String hint,
                T obj)
Receive one message from the test actor and assert that it equals the given object. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
max - (undocumented)
hint - (undocumented)
obj - (undocumented)
Returns:
the received object

expectMsg_internal

<T> T expectMsg_internal(scala.concurrent.duration.Duration max,
                         T obj,
                         scala.Option<java.lang.String> hint)

expectMsgPF

<T> T expectMsgPF(scala.concurrent.duration.Duration max,
                  java.lang.String hint,
                  scala.PartialFunction<java.lang.Object,T> f)
Receive one message from the test actor and assert that the given partial function accepts it. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Use this variant to implement more complicated or conditional processing.

Parameters:
max - (undocumented)
hint - (undocumented)
f - (undocumented)
Returns:
the received object as transformed by the partial function

expectTerminated

Terminated expectTerminated(ActorRef target,
                            scala.concurrent.duration.Duration max)
Receive one message from the test actor and assert that it is the Terminated message of the given ActorRef. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
target - (undocumented)
max - (undocumented)
Returns:
the received Terminated message

fishForMessage

java.lang.Object fishForMessage(scala.concurrent.duration.Duration max,
                                java.lang.String hint,
                                scala.PartialFunction<java.lang.Object,java.lang.Object> f)
Hybrid of expectMsgPF and receiveWhile: receive messages while the partial function matches and returns false. Use it to ignore certain messages while waiting for a specific message.

Parameters:
max - (undocumented)
hint - (undocumented)
f - (undocumented)
Returns:
the last received messsage, i.e. the first one for which the partial function returned true

expectMsgType

<T> T expectMsgType(scala.reflect.ClassTag<T> t)
Same as expectMsgType[T](remaining), but correctly treating the timeFactor.

Parameters:
t - (undocumented)
Returns:
(undocumented)

expectMsgType

<T> T expectMsgType(scala.concurrent.duration.FiniteDuration max,
                    scala.reflect.ClassTag<T> t)
Receive one message from the test actor and assert that it conforms to the given type (after erasure). Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
max - (undocumented)
t - (undocumented)
Returns:
the received object

expectMsgClass

<C> C expectMsgClass(java.lang.Class<C> c)
Same as expectMsgClass(remaining, c), but correctly treating the timeFactor.

Parameters:
c - (undocumented)
Returns:
(undocumented)

expectMsgClass

<C> C expectMsgClass(scala.concurrent.duration.FiniteDuration max,
                     java.lang.Class<C> c)
Receive one message from the test actor and assert that it conforms to the given class. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
max - (undocumented)
c - (undocumented)
Returns:
the received object

expectMsgClass_internal

<C> C expectMsgClass_internal(scala.concurrent.duration.FiniteDuration max,
                              java.lang.Class<C> c)

expectMsgAnyOf

<T> T expectMsgAnyOf(scala.collection.Seq<T> obj)
Same as expectMsgAnyOf(remaining, obj...), but correctly treating the timeFactor.

Parameters:
obj - (undocumented)
Returns:
(undocumented)

expectMsgAnyOf

<T> T expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max,
                     scala.collection.Seq<T> obj)
Receive one message from the test actor and assert that it equals one of the given objects. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
max - (undocumented)
obj - (undocumented)
Returns:
the received object

expectMsgAnyOf_internal

<T> T expectMsgAnyOf_internal(scala.concurrent.duration.FiniteDuration max,
                              scala.collection.Seq<T> obj)

expectMsgAnyClassOf

<C> C expectMsgAnyClassOf(scala.collection.Seq<java.lang.Class<? extends C>> obj)
Same as expectMsgAnyClassOf(remaining, obj...), but correctly treating the timeFactor.

Parameters:
obj - (undocumented)
Returns:
(undocumented)

expectMsgAnyClassOf

<C> C expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max,
                          scala.collection.Seq<java.lang.Class<? extends C>> obj)
Receive one message from the test actor and assert that it conforms to one of the given classes. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
max - (undocumented)
obj - (undocumented)
Returns:
the received object

expectMsgAnyClassOf_internal

<C> C expectMsgAnyClassOf_internal(scala.concurrent.duration.FiniteDuration max,
                                   scala.collection.Seq<java.lang.Class<? extends C>> obj)

expectMsgAllOf

<T> scala.collection.immutable.Seq<T> expectMsgAllOf(scala.collection.Seq<T> obj)
Same as expectMsgAllOf(remaining, obj...), but correctly treating the timeFactor.

Parameters:
obj - (undocumented)
Returns:
(undocumented)

expectMsgAllOf

<T> scala.collection.immutable.Seq<T> expectMsgAllOf(scala.concurrent.duration.FiniteDuration max,
                                                     scala.collection.Seq<T> obj)
Receive a number of messages from the test actor matching the given number of objects and assert that for each given object one is received which equals it and vice versa. This construct is useful when the order in which the objects are received is not fixed. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

   dispatcher ! SomeWork1()
   dispatcher ! SomeWork2()
   expectMsgAllOf(1 second, Result1(), Result2())
 

Parameters:
max - (undocumented)
obj - (undocumented)
Returns:
(undocumented)

checkMissingAndUnexpected

void checkMissingAndUnexpected(scala.collection.Seq<java.lang.Object> missing,
                               scala.collection.Seq<java.lang.Object> unexpected,
                               java.lang.String missingMessage,
                               java.lang.String unexpectedMessage)

expectMsgAllOf_internal

<T> scala.collection.immutable.Seq<T> expectMsgAllOf_internal(scala.concurrent.duration.FiniteDuration max,
                                                              scala.collection.Seq<T> obj)

expectMsgAllClassOf

<T> scala.collection.immutable.Seq<T> expectMsgAllClassOf(scala.collection.Seq<java.lang.Class<? extends T>> obj)
Same as expectMsgAllClassOf(remaining, obj...), but correctly treating the timeFactor.

Parameters:
obj - (undocumented)
Returns:
(undocumented)

expectMsgAllClassOf

<T> scala.collection.immutable.Seq<T> expectMsgAllClassOf(scala.concurrent.duration.FiniteDuration max,
                                                          scala.collection.Seq<java.lang.Class<? extends T>> obj)
Receive a number of messages from the test actor matching the given number of classes and assert that for each given class one is received which is of that class (equality, not conformance). This construct is useful when the order in which the objects are received is not fixed. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Parameters:
max - (undocumented)
obj - (undocumented)
Returns:
(undocumented)

internalExpectMsgAllClassOf

<T> scala.collection.immutable.Seq<T> internalExpectMsgAllClassOf(scala.concurrent.duration.FiniteDuration max,
                                                                  scala.collection.Seq<java.lang.Class<? extends T>> obj)

expectMsgAllConformingOf

<T> scala.collection.immutable.Seq<T> expectMsgAllConformingOf(scala.collection.Seq<java.lang.Class<? extends T>> obj)
Same as expectMsgAllConformingOf(remaining, obj...), but correctly treating the timeFactor.

Parameters:
obj - (undocumented)
Returns:
(undocumented)

expectMsgAllConformingOf

<T> scala.collection.immutable.Seq<T> expectMsgAllConformingOf(scala.concurrent.duration.FiniteDuration max,
                                                               scala.collection.Seq<java.lang.Class<? extends T>> obj)
Receive a number of messages from the test actor matching the given number of classes and assert that for each given class one is received which conforms to that class (and vice versa). This construct is useful when the order in which the objects are received is not fixed. Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.

Beware that one object may satisfy all given class constraints, which may be counter-intuitive.

Parameters:
max - (undocumented)
obj - (undocumented)
Returns:
(undocumented)

internalExpectMsgAllConformingOf

<T> scala.collection.immutable.Seq<T> internalExpectMsgAllConformingOf(scala.concurrent.duration.FiniteDuration max,
                                                                       scala.collection.Seq<java.lang.Class<? extends T>> obj)

expectNoMsg

void expectNoMsg()
Same as expectNoMsg(remaining), but correctly treating the timeFactor.


expectNoMsg

void expectNoMsg(scala.concurrent.duration.FiniteDuration max)
Assert that no message is received for the specified time.

Parameters:
max - (undocumented)

expectNoMsg_internal

void expectNoMsg_internal(scala.concurrent.duration.FiniteDuration max)

receiveWhile

<T> scala.collection.immutable.Seq<T> receiveWhile(scala.concurrent.duration.Duration max,
                                                   scala.concurrent.duration.Duration idle,
                                                   int messages,
                                                   scala.PartialFunction<java.lang.Object,T> f)
Receive a series of messages until one does not match the given partial function or the idle timeout is met (disabled by default) or the overall maximum duration is elapsed. Returns the sequence of messages.

Note that it is not an error to hit the max duration in this case.

One possible use of this method is for testing whether messages of certain characteristics are generated at a certain rate:

 test ! ScheduleTicks(100 millis)
 val series = receiveWhile(750 millis) {
     case Tick(count) => count
 }
 assert(series == (1 to 7).toList)
 

Parameters:
max - (undocumented)
idle - (undocumented)
messages - (undocumented)
f - (undocumented)
Returns:
(undocumented)

receiveN

scala.collection.immutable.Seq<java.lang.Object> receiveN(int n)
Same as receiveN(n, remaining) but correctly taking into account Duration.timeFactor.

Parameters:
n - (undocumented)
Returns:
(undocumented)

receiveN

scala.collection.immutable.Seq<java.lang.Object> receiveN(int n,
                                                          scala.concurrent.duration.FiniteDuration max)
Receive N messages in a row before the given deadline.

Parameters:
n - (undocumented)
max - (undocumented)
Returns:
(undocumented)

receiveN_internal

scala.collection.immutable.Seq<java.lang.Object> receiveN_internal(int n,
                                                                   scala.concurrent.duration.Duration max)

receiveOne

java.lang.Object receiveOne(scala.concurrent.duration.Duration max)
Receive one message from the internal queue of the TestActor. If the given duration is zero, the queue is polled (non-blocking).

This method does NOT automatically scale its Duration parameter!

Parameters:
max - (undocumented)
Returns:
(undocumented)

shutdown

void shutdown(ActorSystem actorSystem,
              scala.concurrent.duration.Duration duration,
              boolean verifySystemShutdown)
Shut down an actor system and wait for termination. On failure debug output will be logged about the remaining actors in the system.

If verifySystemShutdown is true, then an exception will be thrown on failure.

Parameters:
actorSystem - (undocumented)
duration - (undocumented)
verifySystemShutdown - (undocumented)

format

java.lang.String format(java.util.concurrent.TimeUnit u,
                        scala.concurrent.duration.Duration d)