akka.testkit

TestProbe

class TestProbe extends TestKit

TestKit-based probe which allows sending, reception and reply.

Linear Supertypes
TestKit, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. TestProbe
  2. TestKit
  3. AnyRef
  4. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TestProbe(_application: ActorSystem)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def awaitCond(p: ⇒ Boolean, max: Duration = Duration.Undefined, interval: Duration = 100.millis): Unit

    Await until the given condition evaluates to true or the timeout expires, whichever comes first.

    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".

    Definition Classes
    TestKit
  8. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  9. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  10. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  11. def expectMsg[T](max: Duration, obj: T): T

    Receive one message from the test actor and assert that it equals the given object.

    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.

    returns

    the received object

    Definition Classes
    TestKit
  12. def expectMsg[T](obj: T): T

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

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

    Definition Classes
    TestKit
  13. def expectMsgAllClassOf[T](max: Duration, obj: Class[_ <: T]*): Seq[T]

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

    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.

    Definition Classes
    TestKit
  14. def expectMsgAllClassOf[T](obj: Class[_ <: T]*): Seq[T]

    Same as expectMsgAllClassOf(remaining, obj...), but correctly treating the timeFactor.

    Same as expectMsgAllClassOf(remaining, obj...), but correctly treating the timeFactor.

    Definition Classes
    TestKit
  15. def expectMsgAllConformingOf[T](max: Duration, obj: Class[_ <: T]*): Seq[T]

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

    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.

    Definition Classes
    TestKit
  16. def expectMsgAllConformingOf[T](obj: Class[_ <: T]*): Seq[T]

    Same as expectMsgAllConformingOf(remaining, obj...), but correctly treating the timeFactor.

    Same as expectMsgAllConformingOf(remaining, obj...), but correctly treating the timeFactor.

    Definition Classes
    TestKit
  17. def expectMsgAllOf[T](max: Duration, obj: T*): Seq[T]

    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.

    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())
    

    Definition Classes
    TestKit
  18. def expectMsgAllOf[T](obj: T*): Seq[T]

    Same as expectMsgAllOf(remaining, obj...), but correctly treating the timeFactor.

    Same as expectMsgAllOf(remaining, obj...), but correctly treating the timeFactor.

    Definition Classes
    TestKit
  19. def expectMsgAnyClassOf[C](max: Duration, obj: Class[_ <: C]*): C

    Receive one message from the test actor and assert that it conforms to one of the given classes.

    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.

    returns

    the received object

    Definition Classes
    TestKit
  20. def expectMsgAnyClassOf[C](obj: Class[_ <: C]*): C

    Same as expectMsgAnyClassOf(remaining, obj...), but correctly treating the timeFactor.

    Same as expectMsgAnyClassOf(remaining, obj...), but correctly treating the timeFactor.

    Definition Classes
    TestKit
  21. def expectMsgAnyOf[T](max: Duration, obj: T*): T

    Receive one message from the test actor and assert that it equals one of the given objects.

    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.

    returns

    the received object

    Definition Classes
    TestKit
  22. def expectMsgAnyOf[T](obj: T*): T

    Same as expectMsgAnyOf(remaining, obj...), but correctly treating the timeFactor.

    Same as expectMsgAnyOf(remaining, obj...), but correctly treating the timeFactor.

    Definition Classes
    TestKit
  23. def expectMsgClass[C](max: Duration, c: Class[C]): C

    Receive one message from the test actor and assert that it conforms to the given class.

    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.

    returns

    the received object

    Definition Classes
    TestKit
  24. def expectMsgClass[C](c: Class[C]): C

    Same as expectMsgClass(remaining, c), but correctly treating the timeFactor.

    Same as expectMsgClass(remaining, c), but correctly treating the timeFactor.

    Definition Classes
    TestKit
  25. def expectMsgPF[T](max: Duration = Duration.Undefined, hint: String = "")(f: PartialFunction[Any, T]): T

    Receive one message from the test actor and assert that the given partial function accepts it.

    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.

    returns

    the received object as transformed by the partial function

    Definition Classes
    TestKit
  26. def expectMsgType[T](max: Duration)(implicit m: Manifest[T]): T

    Receive one message from the test actor and assert that it conforms to the given type (after erasure).

    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.

    returns

    the received object

    Definition Classes
    TestKit
  27. def expectMsgType[T](implicit m: Manifest[T]): T

    Same as expectMsgType[T](remaining), but correctly treating the timeFactor.

    Same as expectMsgType[T](remaining), but correctly treating the timeFactor.

    Definition Classes
    TestKit
  28. def expectNoMsg(max: Duration): Unit

    Assert that no message is received for the specified time.

    Assert that no message is received for the specified time.

    Definition Classes
    TestKit
  29. def expectNoMsg(): Unit

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

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

    Definition Classes
    TestKit
  30. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  31. def fishForMessage(max: Duration = Duration.Undefined, hint: String = "")(f: PartialFunction[Any, Boolean]): Any

    Hybrid of expectMsgPF and receiveWhile: receive messages while the partial function matches and returns false.

    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.

    returns

    the last received messsage, i.e. the first one for which the partial function returned true

    Definition Classes
    TestKit
  32. def forward(actor: ActorRef, msg: AnyRef = lastMessage.msg): Unit

    Forward this message as if in the TestActor's receive method with self.

    Forward this message as if in the TestActor's receive method with self.forward.

  33. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  34. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  35. def ignoreMsg(f: PartialFunction[AnyRef, Boolean]): Unit

    Ignore all messages in the test actor for which the given partial function returns true.

    Ignore all messages in the test actor for which the given partial function returns true.

    Definition Classes
    TestKit
  36. def ignoreNoMsg(): Unit

    Stop ignoring messages in the test actor.

    Stop ignoring messages in the test actor.

    Definition Classes
    TestKit
  37. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  38. def lastSender: ActorRef

    Definition Classes
    TestKit
  39. def msgAvailable: Boolean

    Query queue status.

    Query queue status.

    Definition Classes
    TestKit
  40. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  41. final def notify(): Unit

    Definition Classes
    AnyRef
  42. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  43. def now: Duration

    Obtain current time (System.nanoTime) as Duration.

    Obtain current time (System.nanoTime) as Duration.

    Definition Classes
    TestKit
  44. def receiveN(n: Int, max: Duration): Seq[AnyRef]

    Receive N messages in a row before the given deadline.

    Receive N messages in a row before the given deadline.

    Definition Classes
    TestKit
  45. def receiveN(n: Int): Seq[AnyRef]

    Same as receiveN(n, remaining) but correctly taking into account Duration.

    Same as receiveN(n, remaining) but correctly taking into account Duration.timeFactor.

    Definition Classes
    TestKit
  46. def receiveOne(max: Duration): AnyRef

    Receive one message from the internal queue of the TestActor.

    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!

    Definition Classes
    TestKit
  47. def receiveWhile[T](max: Duration = Duration.Undefined, idle: Duration = Duration.Inf, messages: Int = Int.MaxValue)(f: PartialFunction[AnyRef, T]): Seq[T]

    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.

    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)
    

    Definition Classes
    TestKit
  48. def ref: ActorRef

    Shorthand to get the testActor.

  49. def remaining: Duration

    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.

    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").

    Definition Classes
    TestKit
  50. def send(actor: ActorRef, msg: AnyRef): Unit

    Send message to an actor while using the probe's TestActor as the sender.

    Send message to an actor while using the probe's TestActor as the sender. Replies will be available for inspection with all of TestKit's assertion methods.

  51. def sender: ActorRef

    Get sender of last received message.

  52. def setAutoPilot(pilot: AutoPilot): Unit

    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.

    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.

    Definition Classes
    TestKit
  53. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  54. implicit val system: ActorSystem

    Definition Classes
    TestKit
  55. lazy val testActor: ActorRef

    ActorRef of the test actor.

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

    Definition Classes
    TestKit
  56. val testKitSettings: TestKitSettings

    Definition Classes
    TestKit
  57. def toString(): String

    Definition Classes
    AnyRef → Any
  58. def unwatch(ref: ActorRef): Unit

    Have the testActor stop watching someone (i.

    Have the testActor stop watching someone (i.e. context.unwatch(...)). Waits until the Watch message is received back using expectMsg.

    Definition Classes
    TestKit
  59. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  60. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  61. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  62. def watch(ref: ActorRef): Unit

    Have the testActor watch someone (i.

    Have the testActor watch someone (i.e. context.watch(...)). Waits until the Watch message is received back using expectMsg.

    Definition Classes
    TestKit
  63. def within[T](max: Duration)(f: ⇒ T): T

    Same as calling within(0 seconds, max)(f).

    Same as calling within(0 seconds, max)(f).

    Definition Classes
    TestKit
  64. def within[T](min: Duration, max: Duration)(f: ⇒ T): T

    Execute code block while bounding its execution time between min and max.

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

    Definition Classes
    TestKit

Inherited from TestKit

Inherited from AnyRef

Inherited from Any