TestFSMRef

org.apache.pekko.testkit.TestFSMRef
See theTestFSMRef companion object
class TestFSMRef[S, D, T <: Actor](system: ActorSystem, props: Props, supervisor: ActorRef, name: String)(implicit ev: T <:< FSM[S, D]) extends TestActorRef[T]

This is a specialized 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 Event("hello", _) => goto(2)
   }
   when(2) {
     case Event("world", _) => goto(1)
   }
 })
assert (fsm.stateName == 1)
fsm ! "hallo"
assert (fsm.stateName == 2)
assert (fsm.underlyingActor.getLog == IndexedSeq(FSMLogEntry(1, null, "hallo")))

Attributes

Since

1.2

Companion
object
Source
TestFSMRef.scala
Graph
Supertypes
class TestActorRef[T]
class ActorRef
trait Serializable
trait Comparable[ActorRef]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def setState(stateName: S, stateData: D, timeout: FiniteDuration, stopReason: Option[Reason]): Unit

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.

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.

Attributes

Source
TestFSMRef.scala
def stateData: D

Get current state data of this FSM.

Get current state data of this FSM.

Attributes

Source
TestFSMRef.scala
def stateName: S

Get current state name of this FSM.

Get current state name of this FSM.

Attributes

Source
TestFSMRef.scala

Deprecated methods

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

Attributes

Deprecated
[Since version Akka 2.6.0]
Source
TestFSMRef.scala

Inherited methods

override def !(message: Any)(implicit sender: ActorRef): Unit

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

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

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
final def compareTo(other: ActorRef): Int

Comparison takes path and the unique id of the actor cell into account.

Comparison takes path and the unique id of the actor cell into account.

Attributes

Inherited from:
ActorRef
Source
ActorRef.scala
final override def equals(that: Any): Boolean

Equals takes path and the unique id of the actor cell into account.

Equals takes path and the unique id of the actor cell into account.

Attributes

Definition Classes
ActorRef -> Any
Inherited from:
ActorRef
Source
ActorRef.scala
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, no matter whether originally sent with tell/'!' or ask/'?'.

Attributes

Inherited from:
ActorRef
Source
ActorRef.scala
override def getChild(names: Iterator[String]): InternalActorRef

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.

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.

Attributes

Definition Classes
Inherited from:
l.getParent case""=> l caseany=> l.getSingleChild(any) } if(next.==(Nobody).||(name.isEmpty))nextelserec(next,name) case_=> ref.getChild(name) } if(names.isEmpty)thiselserec(this,names) }">LocalActorRef (hidden)
Source
ActorRef.scala
override def getParent: InternalActorRef

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

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

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
def getSingleChild(name: String): InternalActorRef

Method for looking up a single child beneath this actor. Override in order to inject “synthetic” actor paths like “/temp”. It is racy if called from the outside.

Method for looking up a single child beneath this actor. Override in order to inject “synthetic” actor paths like “/temp”. It is racy if called from the outside.

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
final override def hashCode: Int

Calculate a hash code value for the object.

Calculate a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
ActorRef -> Any
Inherited from:
ActorRef
Source
ActorRef.scala
final def isLocal: Boolean

Attributes

Inherited from:
LocalRef (hidden)
Source
ActorRef.scala
override 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.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
def receive(o: Any, sender: ActorRef): Unit

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

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

Attributes

Inherited from:
TestActorRef
Source
TestActorRef.scala
def receive(o: Any): Unit

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

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

Attributes

Inherited from:
TestActorRef
Source
TestActorRef.scala
override def restart(cause: Throwable): Unit

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala

Resumes a suspended actor.

Resumes a suspended actor.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def sendSystemMessage(message: SystemMessage): Unit

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def start(): Unit

Starts the actor after initialization.

Starts the actor after initialization.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def stop(): Unit

Shuts down the actor and its message queue

Shuts down the actor and its message queue

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
override def suspend(): Unit

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.

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.

Attributes

Definition Classes
Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala
final def tell(msg: Any, sender: ActorRef): Unit

Sends the specified message to this ActorRef, i.e. fire-and-forget semantics, including the sender reference if possible.

Sends the specified message to this ActorRef, i.e. fire-and-forget semantics, including the sender reference if possible.

Pass pekko.actor.ActorRef noSender or null as sender if there is nobody to reply to

Attributes

Inherited from:
ActorRef
Source
ActorRef.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Inherited from:
TestActorRef
Source
TestActorRef.scala
def underlying: ActorCell

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala

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.

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.

Attributes

Inherited from:
TestActorRef
Source
TestActorRef.scala
def unwatch(subject: ActorRef): ActorRef

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

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

Attributes

Returns

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

Inherited from:
TestActorRef
Source
TestActorRef.scala
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.

Attributes

Returns

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

Inherited from:
TestActorRef
Source
TestActorRef.scala

Inherited fields

Attributes

Inherited from:
TestActorRef
Source
TestActorRef.scala
override 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).

Attributes

Inherited from:
LocalActorRef (hidden)
Source
ActorRef.scala