Package akka.testkit
Class TestFSMRef<S,D,T extends Actor>
- java.lang.Object
-
- akka.actor.LocalActorRef
-
- akka.testkit.TestActorRef<T>
-
- akka.testkit.TestFSMRef<S,D,T>
-
public class TestFSMRef<S,D,T extends Actor> 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")))
- Since:
- 1.2
-
-
Constructor Summary
Constructors Constructor Description TestFSMRef(ActorSystem system, Props props, ActorRef supervisor, java.lang.String name, scala.$less$colon$less<T,FSM<S,D>> ev)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <S,D,T extends Actor>
TestFSMRef<S,D,T>apply(scala.Function0<T> factory, ActorRef supervisor, java.lang.String name, scala.reflect.ClassTag<T> evidence$3, scala.$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, ActorRef supervisor, scala.reflect.ClassTag<T> evidence$4, scala.$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.$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, scala.reflect.ClassTag<T> evidence$1, scala.$less$colon$less<T,FSM<S,D>> ev, ActorSystem system)
void
cancelTimer(java.lang.String name)
Proxy forFSM.cancelTimer(java.lang.String)
.boolean
isStateTimerActive()
Proxy forFSM.isStateTimerActive()
.boolean
isTimerActive(java.lang.String name)
Proxy forFSM.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).S
setState$default$1()
D
setState$default$2()
scala.concurrent.duration.FiniteDuration
setState$default$3()
scala.Option<FSM.Reason>
setState$default$4()
void
setTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, boolean repeat)
Deprecated.Use startTimerWithFixedDelay or startTimerAtFixedRate instead.boolean
setTimer$default$4()
void
startSingleTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
void
startTimerAtFixedRate(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration interval)
void
startTimerWithFixedDelay(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
D
stateData()
Get current state data of this FSM.S
stateName()
Get current state name of this FSM.
-
-
-
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.$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.$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, ActorRef supervisor, java.lang.String name, scala.reflect.ClassTag<T> evidence$3, scala.$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, ActorRef supervisor, scala.reflect.ClassTag<T> evidence$4, scala.$less$colon$less<T,FSM<S,D>> ev, ActorSystem system)
-
stateName
public S stateName()
Get current state name of this FSM.
-
stateData
public D stateData()
Get current state data of this FSM.
-
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.
-
setState$default$1
public S setState$default$1()
-
setState$default$2
public D setState$default$2()
-
setState$default$3
public scala.concurrent.duration.FiniteDuration setState$default$3()
-
setState$default$4
public scala.Option<FSM.Reason> setState$default$4()
-
startTimerWithFixedDelay
public void startTimerWithFixedDelay(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
-
startTimerAtFixedRate
public void startTimerAtFixedRate(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration interval)
-
startSingleTimer
public void startSingleTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration delay)
-
setTimer
public void setTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, boolean repeat)
Deprecated.Use startTimerWithFixedDelay or startTimerAtFixedRate instead. This has the same semantics as startTimerAtFixedRate, but startTimerWithFixedDelay is often preferred. Since 2.6.0.
-
setTimer$default$4
public boolean setTimer$default$4()
-
cancelTimer
public void cancelTimer(java.lang.String name)
Proxy forFSM.cancelTimer(java.lang.String)
.
-
isTimerActive
public boolean isTimerActive(java.lang.String name)
Proxy forFSM.isStateTimerActive()
.
-
isStateTimerActive
public boolean isStateTimerActive()
Proxy forFSM.isStateTimerActive()
.
-
-