akka.testkit

TestFSMRef

class TestFSMRef[S, D, T <: Actor] extends TestActorRef[Nothing]

This is a specialised form of the TestActorRef with support for querying and setting the state of a FSM. Use a LoggingFSM with this class if you also need to inspect event traces.


val fsm = TestFSMRef(new Actor with LoggingFSM[Int, Null] {
    override def logDepth = 12
    startWith(1, null)
    when(1) {
      case Ev("hello") => goto(2)
    }
    when(2) {
      case Ev("world") => goto(1)
    }
  }
assert (fsm.stateName == 1)
fsm ! "hallo"
assert (fsm.stateName == 2)
assert (fsm.underlyingActor.getLog == IndexedSeq(FSMLogEntry(1, null, "hallo")))

Since

1.2

Linear Supertypes
TestActorRef[Nothing], LocalActorRef, LocalRef, ActorRefScope, ActorRefWithCell, InternalActorRef, ScalaActorRef, ActorRef, Serializable, Serializable, Comparable[ActorRef], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. TestFSMRef
  2. TestActorRef
  3. LocalActorRef
  4. LocalRef
  5. ActorRefScope
  6. ActorRefWithCell
  7. InternalActorRef
  8. ScalaActorRef
  9. ActorRef
  10. Serializable
  11. Serializable
  12. Comparable
  13. AnyRef
  14. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TestFSMRef(system: ActorSystemImpl, _prerequisites: DispatcherPrerequisites, props: Props, supervisor: InternalActorRef, name: String)(implicit ev: <:<[T, FSM[S, D]])

Value Members

  1. def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit

    Sends a one-way asynchronous message.

    Sends a one-way asynchronous message. E.g. fire-and-forget semantics.

    If invoked from within an actor then the actor reference is implicitly passed on as the implicit 'sender' argument.

    This actor 'sender' reference is then available in the receiving actor in the 'sender' member variable, if invoked from within an Actor. If not then no sender is available.

      actor ! message
    

    Definition Classes
    LocalActorRef → ScalaActorRef
  2. final def !=(arg0: AnyRef): Boolean

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

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

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

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

    Definition Classes
    Any
  7. def actorContext: ActorContext

    Attributes
    protected
    Definition Classes
    LocalActorRef
  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def cancelTimer(name: String): Unit

    Proxy for FSM.

    Proxy for FSM.cancelTimer.

  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  11. final def compareTo(other: ActorRef): Int

    Comparison only takes address into account.

    Comparison only takes address into account.

    Definition Classes
    ActorRef → Comparable
  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. final def equals(that: Any): Boolean

    Definition Classes
    ActorRef → AnyRef → Any
  14. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  15. def forward(message: Any)(implicit context: ActorContext): Unit

    Forwards the message and passes the original sender actor as the sender.

    Forwards the message and passes the original sender actor as the sender.

    Works with '!' and '?'/'ask'.

    Definition Classes
    ActorRef
  16. def getChild(names: Iterator[String]): InternalActorRef

    Obtain ActorRef by possibly traversing the actor tree or looking it up at some provider-specific location.

    Obtain ActorRef by possibly traversing the actor tree or looking it up at some provider-specific location. This method shall return the end result, i.e. not only the next step in the look-up; this will typically involve recursive invocation. A path element of ".." signifies the parent, a trailing "" element must be disregarded. If the requested path does not exist, return Nobody.

    Definition Classes
    LocalActorRef → InternalActorRef
  17. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  18. def getParent: InternalActorRef

    Obtain parent of this ref; used by getChild for ".

    Obtain parent of this ref; used by getChild for ".." paths.

    Definition Classes
    LocalActorRef → InternalActorRef
  19. def getSingleChild(name: String): InternalActorRef

    Method for looking up a single child beneath this actor.

    Method for looking up a single child beneath this actor. Override in order to inject “synthetic” actor paths like “/temp”.

    Attributes
    protected
    Definition Classes
    LocalActorRef
  20. final def hashCode(): Int

    Definition Classes
    ActorRef → AnyRef → Any
  21. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  22. final def isLocal: Boolean

    Definition Classes
    LocalRef → ActorRefScope
  23. def isTerminated: Boolean

    Is the actor terminated? If this method returns true, it will never return false again, but if it returns false, you cannot be sure if it's alive still (race condition)

    Is the actor terminated? If this method returns true, it will never return false again, but if it returns false, you cannot be sure if it's alive still (race condition)

    Definition Classes
    LocalActorRef → ActorRef
  24. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  25. def newActorCell(system: ActorSystemImpl, ref: InternalActorRef, props: Props, supervisor: InternalActorRef): ActorCell

    Definition Classes
    TestActorRef → LocalActorRef
  26. final def notify(): Unit

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

    Definition Classes
    AnyRef
  28. val path: ActorPath

    Returns the path for this actor (from this actor up to the root actor).

    Returns the path for this actor (from this actor up to the root actor).

    Definition Classes
    LocalActorRef → ActorRef
  29. def provider: ActorRefProvider

    Get a reference to the actor ref provider which created this ref.

    Get a reference to the actor ref provider which created this ref.

    Definition Classes
    LocalActorRef → InternalActorRef
  30. def receive(o: Any, sender: ActorRef): Unit

    Directly inject messages into actor receive behavior.

    Directly inject messages into actor receive behavior. Any exceptions thrown will be available to you, while still being able to use become/unbecome.

    Definition Classes
    TestActorRef
  31. def receive(o: Any): Unit

    Directly inject messages into actor receive behavior.

    Directly inject messages into actor receive behavior. Any exceptions thrown will be available to you, while still being able to use become/unbecome.

    Definition Classes
    TestActorRef
  32. def restart(cause: Throwable): Unit

    Definition Classes
    LocalActorRef → InternalActorRef
  33. def resume(causedByFailure: Throwable): Unit

    Resumes a suspended actor.

    Resumes a suspended actor.

    Definition Classes
    LocalActorRef → InternalActorRef
  34. def sendSystemMessage(message: SystemMessage): Unit

    Definition Classes
    LocalActorRef → InternalActorRef
  35. def setState(stateName: S = fsm.stateName, stateData: D = fsm.stateData, timeout: FiniteDuration = null, stopReason: Option[Reason] = None): Unit

    Change FSM state; any value left out defaults to the current FSM state (timeout defaults to None).

    Change FSM state; any value left out defaults to the current FSM state (timeout defaults to None). This method is directly equivalent to a corresponding transition initiated from within the FSM, including timeout and stop handling.

  36. def setTimer(name: String, msg: Any, timeout: FiniteDuration, repeat: Boolean): Unit

    Proxy for FSM.

    Proxy for FSM.setTimer.

  37. def start(): Unit

    Starts the actor after initialization.

    Starts the actor after initialization.

    Definition Classes
    LocalActorRef → InternalActorRef
  38. def stateData: D

    Get current state data of this FSM.

  39. def stateName: S

    Get current state name of this FSM.

  40. def stop(): Unit

    Shuts down the actor and its message queue

    Shuts down the actor and its message queue

    Definition Classes
    LocalActorRef → InternalActorRef
  41. def suspend(): Unit

    Suspends the actor so that it will not process messages until resumed.

    Suspends the actor so that it will not process messages until resumed. The suspend request is processed asynchronously to the caller of this method as well as to normal message sends: the only ordering guarantee is that message sends done from the same thread after calling this method will not be processed until resumed.

    Definition Classes
    LocalActorRef → InternalActorRef
  42. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  43. final def tell(msg: Any, sender: ActorRef): Unit

    Java API: Sends the specified message to the sender, i.

    Java API: Sends the specified message to the sender, i.e. fire-and-forget semantics, including the sender reference if possible (pass null if there is nobody to reply to).

    actor.tell(message, context);
    

    Definition Classes
    ActorRef
  44. def timerActive_?(name: String): Boolean

    Proxy for FSM.

    Proxy for FSM.timerActive_?.

  45. def toString(): String

    Definition Classes
    TestActorRefActorRef → AnyRef → Any
  46. def underlying: ActorCell

    Definition Classes
    LocalActorRef → ActorRefWithCell
  47. def underlyingActor: Nothing

    Retrieve reference to the underlying actor, where the static type matches the factory used inside the constructor.

    Retrieve reference to the underlying actor, where the static type matches the factory used inside the constructor. Beware that this reference is discarded by the ActorRef upon restarting the actor (should this reference be linked to a supervisor). The old Actor may of course still be used in post-mortem assertions.

    Definition Classes
    TestActorRef
  48. def unwatch(subject: ActorRef): ActorRef

    Deregisters this actor from being a death monitor of the provided ActorRef This means that this actor will not get a Terminated()-message when the provided actor is permanently terminated.

    Deregisters this actor from being a death monitor of the provided ActorRef This means that this actor will not get a Terminated()-message when the provided actor is permanently terminated.

    returns

    the same ActorRef that is provided to it, to allow for cleaner invocations

    Definition Classes
    TestActorRef
  49. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws()
  52. def watch(subject: ActorRef): ActorRef

    Registers this actor to be a death monitor of the provided ActorRef This means that this actor will get a Terminated()-message when the provided actor is permanently terminated.

    Registers this actor to be a death monitor of the provided ActorRef This means that this actor will get a Terminated()-message when the provided actor is permanently terminated.

    returns

    the same ActorRef that is provided to it, to allow for cleaner invocations

    Definition Classes
    TestActorRef
  53. def writeReplace(): AnyRef

    Attributes
    protected
    Definition Classes
    LocalActorRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. final def tell(msg: Any): Unit

    Sends the specified message to the sender, i.

    Sends the specified message to the sender, i.e. fire-and-forget semantics.

    actor.tell(message);
    

    Definition Classes
    ActorRef
    Annotations
    @deprecated
    Deprecated

    (Since version 2.1) use the two-arg variant (typically getSelf() as second arg)

Inherited from TestActorRef[Nothing]

Inherited from LocalActorRef

Inherited from LocalRef

Inherited from ActorRefScope

Inherited from ActorRefWithCell

Inherited from InternalActorRef

Inherited from ScalaActorRef

Inherited from ActorRef

Inherited from Serializable

Inherited from Serializable

Inherited from Comparable[ActorRef]

Inherited from AnyRef

Inherited from Any

Ungrouped