akka.testkit
Class TestFSMRef<S,D,T extends Actor>

java.lang.Object
  extended by akka.actor.ActorRef
      extended by akka.actor.InternalActorRef
          extended by akka.actor.ActorRefWithCell
              extended by akka.actor.LocalActorRef
                  extended by akka.testkit.TestActorRef<T>
                      extended by akka.testkit.TestFSMRef<S,D,T>
All Implemented Interfaces:
ActorRefScope, LocalRef, ScalaActorRef, java.io.Serializable, java.lang.Comparable<ActorRef>

public class TestFSMRef<S,D,T extends Actor>
extends TestActorRef<T>

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") =&gt; goto(2)
     }
     when(2) {
       case Ev("world") =&gt; goto(1)
     }
   }
 assert (fsm.stateName == 1)
 fsm ! "hallo"
 assert (fsm.stateName == 2)
 assert (fsm.underlyingActor.getLog == IndexedSeq(FSMLogEntry(1, null, "hallo")))
 

Since:
1.2
See Also:
Serialized Form

Constructor Summary
TestFSMRef(ActorSystem system, Props props, ActorRef supervisor, java.lang.String name, scala.Predef.$less$colon$less<T,FSM<S,D>> ev)
           
 
Method Summary
static
<S,D,T extends Actor>
TestFSMRef<S,D,T>
apply(scala.Function0<T> factory, scala.reflect.ClassTag<T> evidence$1, scala.Predef.$less$colon$less<T,FSM<S,D>> ev, ActorSystem system)
           
static
<S,D,T extends Actor>
TestFSMRef<S,D,T>
apply(scala.Function0<T> factory, java.lang.String name, scala.reflect.ClassTag<T> evidence$2, scala.Predef.$less$colon$less<T,FSM<S,D>> ev, ActorSystem system)
           
 void cancelTimer(java.lang.String name)
          Proxy for FSM.cancelTimer(java.lang.String).
 boolean isStateTimerActive()
          Proxy for FSM.isStateTimerActive().
 boolean isTimerActive(java.lang.String name)
          Proxy for FSM.isStateTimerActive().
 void setState(S stateName, D stateData, scala.concurrent.duration.FiniteDuration timeout, scala.Option<FSM.Reason> stopReason)
          Change FSM state; any value left out defaults to the current FSM state (timeout defaults to None).
 void setTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, boolean repeat)
          Proxy for FSM.setTimer(java.lang.String, java.lang.Object, scala.concurrent.duration.FiniteDuration, boolean).
 D stateData()
          Get current state data of this FSM.
 S stateName()
          Get current state name of this FSM.
 
Methods inherited from class akka.testkit.TestActorRef
apply, apply, apply, apply, apply, apply, apply, create, create, dispatcher, newActorCell, props, randomName, receive, receive, toString, underlyingActor, unwatch, watch
 
Methods inherited from class akka.actor.LocalActorRef
actorContext, children, getChild, getParent, getSingleChild, isTerminated, path, provider, restart, resume, sendSystemMessage, start, stop, suspend, underlying, writeReplace
 
Methods inherited from class akka.actor.InternalActorRef
isLocal
 
Methods inherited from class akka.actor.ActorRef
compareTo, equals, forward, hashCode, noSender, tell
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface akka.actor.LocalRef
isLocal
 

Constructor Detail

TestFSMRef

public TestFSMRef(ActorSystem system,
                  Props props,
                  ActorRef supervisor,
                  java.lang.String name,
                  scala.Predef.$less$colon$less<T,FSM<S,D>> ev)
Method Detail

apply

public static <S,D,T extends Actor> TestFSMRef<S,D,T> apply(scala.Function0<T> factory,
                                                            scala.reflect.ClassTag<T> evidence$1,
                                                            scala.Predef.$less$colon$less<T,FSM<S,D>> ev,
                                                            ActorSystem system)

apply

public static <S,D,T extends Actor> TestFSMRef<S,D,T> apply(scala.Function0<T> factory,
                                                            java.lang.String name,
                                                            scala.reflect.ClassTag<T> evidence$2,
                                                            scala.Predef.$less$colon$less<T,FSM<S,D>> ev,
                                                            ActorSystem system)

stateName

public S stateName()
Get current state name of this FSM.

Returns:
(undocumented)

stateData

public D stateData()
Get current state data of this FSM.

Returns:
(undocumented)

setState

public void setState(S stateName,
                     D stateData,
                     scala.concurrent.duration.FiniteDuration timeout,
                     scala.Option<FSM.Reason> stopReason)
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.

Parameters:
stateName - (undocumented)
stateData - (undocumented)
timeout - (undocumented)
stopReason - (undocumented)

setTimer

public void setTimer(java.lang.String name,
                     java.lang.Object msg,
                     scala.concurrent.duration.FiniteDuration timeout,
                     boolean repeat)
Proxy for FSM.setTimer(java.lang.String, java.lang.Object, scala.concurrent.duration.FiniteDuration, boolean).

Parameters:
name - (undocumented)
msg - (undocumented)
timeout - (undocumented)
repeat - (undocumented)

cancelTimer

public void cancelTimer(java.lang.String name)
Proxy for FSM.cancelTimer(java.lang.String).

Parameters:
name - (undocumented)

isTimerActive

public boolean isTimerActive(java.lang.String name)
Proxy for FSM.isStateTimerActive().

Parameters:
name - (undocumented)
Returns:
(undocumented)

isStateTimerActive

public boolean isStateTimerActive()
Proxy for FSM.isStateTimerActive().

Returns:
(undocumented)