Merge branch 'master' of github.com:jboner/akka
This commit is contained in:
commit
e57a48e9e2
12 changed files with 84 additions and 192 deletions
|
|
@ -7,7 +7,6 @@ package akka.actor
|
|||
import org.scalatest.{ BeforeAndAfterAll, BeforeAndAfterEach }
|
||||
import akka.testkit._
|
||||
import TestEvent.Mute
|
||||
import FSM._
|
||||
import akka.util.duration._
|
||||
import akka.event._
|
||||
import com.typesafe.config.ConfigFactory
|
||||
|
|
@ -52,7 +51,7 @@ object FSMActorSpec {
|
|||
}
|
||||
}
|
||||
case Event("hello", _) ⇒ stay replying "world"
|
||||
case Event("bye", _) ⇒ stop(Shutdown)
|
||||
case Event("bye", _) ⇒ stop(FSM.Shutdown)
|
||||
}
|
||||
|
||||
when(Open) {
|
||||
|
|
@ -63,7 +62,7 @@ object FSMActorSpec {
|
|||
}
|
||||
|
||||
whenUnhandled {
|
||||
case Ev(msg) ⇒ {
|
||||
case Event(msg, _) ⇒ {
|
||||
log.warning("unhandled event " + msg + " in state " + stateName + " with data " + stateData)
|
||||
unhandledLatch.open
|
||||
stay
|
||||
|
|
@ -82,7 +81,7 @@ object FSMActorSpec {
|
|||
}
|
||||
|
||||
onTermination {
|
||||
case StopEvent(Shutdown, Locked, _) ⇒
|
||||
case StopEvent(FSM.Shutdown, Locked, _) ⇒
|
||||
// stop is called from lockstate with shutdown as reason...
|
||||
terminatedLatch.open
|
||||
}
|
||||
|
|
@ -110,6 +109,8 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
|
|||
|
||||
"unlock the lock" in {
|
||||
|
||||
import FSM.{ Transition, CurrentState, SubscribeTransitionCallBack }
|
||||
|
||||
val latches = new Latches
|
||||
import latches._
|
||||
|
||||
|
|
@ -163,7 +164,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
|
|||
val fsm = TestActorRef(new Actor with FSM[Int, Null] {
|
||||
startWith(1, null)
|
||||
when(1) {
|
||||
case Ev("go") ⇒ goto(2)
|
||||
case Event("go", _) ⇒ goto(2)
|
||||
}
|
||||
})
|
||||
val name = fsm.path.toString
|
||||
|
|
@ -182,7 +183,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
|
|||
lazy val fsm = new Actor with FSM[Int, Null] {
|
||||
override def preStart = { started.countDown }
|
||||
startWith(1, null)
|
||||
when(1) { NullFunction }
|
||||
when(1) { FSM.NullFunction }
|
||||
onTermination {
|
||||
case x ⇒ testActor ! x
|
||||
}
|
||||
|
|
@ -190,7 +191,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
|
|||
val ref = system.actorOf(Props(fsm))
|
||||
Await.ready(started, timeout.duration)
|
||||
system.stop(ref)
|
||||
expectMsg(1 second, fsm.StopEvent(Shutdown, 1, null))
|
||||
expectMsg(1 second, fsm.StopEvent(FSM.Shutdown, 1, null))
|
||||
}
|
||||
|
||||
"log events and transitions if asked to do so" in {
|
||||
|
|
@ -204,12 +205,12 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
|
|||
val fsm = TestActorRef(new Actor with LoggingFSM[Int, Null] {
|
||||
startWith(1, null)
|
||||
when(1) {
|
||||
case Ev("go") ⇒
|
||||
setTimer("t", Shutdown, 1.5 seconds, false)
|
||||
case Event("go", _) ⇒
|
||||
setTimer("t", FSM.Shutdown, 1.5 seconds, false)
|
||||
goto(2)
|
||||
}
|
||||
when(2) {
|
||||
case Ev("stop") ⇒
|
||||
case Event("stop", _) ⇒
|
||||
cancelTimer("t")
|
||||
stop
|
||||
}
|
||||
|
|
@ -230,7 +231,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
|
|||
expectMsgPF(1 second, hint = "processing Event(stop,null)") {
|
||||
case Logging.Debug(`name`, `fsmClass`, s: String) if s.startsWith("processing Event(stop,null) from Actor[") ⇒ true
|
||||
}
|
||||
expectMsgAllOf(1 second, Logging.Debug(name, fsmClass, "canceling timer 't'"), Normal)
|
||||
expectMsgAllOf(1 second, Logging.Debug(name, fsmClass, "canceling timer 't'"), FSM.Normal)
|
||||
expectNoMsg(1 second)
|
||||
system.eventStream.unsubscribe(testActor)
|
||||
}
|
||||
|
|
@ -251,6 +252,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im
|
|||
})
|
||||
fsmref ! "log"
|
||||
val fsm = fsmref.underlyingActor
|
||||
import FSM.LogEntry
|
||||
expectMsg(1 second, IndexedSeq(LogEntry(1, 0, "log")))
|
||||
fsmref ! "count"
|
||||
fsmref ! "log"
|
||||
|
|
|
|||
|
|
@ -160,37 +160,37 @@ object FSMTimingSpec {
|
|||
|
||||
startWith(Initial, 0)
|
||||
when(Initial) {
|
||||
case Ev(TestSingleTimer) ⇒
|
||||
case Event(TestSingleTimer, _) ⇒
|
||||
setTimer("tester", Tick, 500 millis, false)
|
||||
goto(TestSingleTimer)
|
||||
case Ev(TestRepeatedTimer) ⇒
|
||||
case Event(TestRepeatedTimer, _) ⇒
|
||||
setTimer("tester", Tick, 100 millis, true)
|
||||
goto(TestRepeatedTimer) using 4
|
||||
case Ev(TestStateTimeoutOverride) ⇒
|
||||
case Event(TestStateTimeoutOverride, _) ⇒
|
||||
goto(TestStateTimeout) forMax (Duration.Inf)
|
||||
case Ev(x: FSMTimingSpec.State) ⇒ goto(x)
|
||||
case Event(x: FSMTimingSpec.State, _) ⇒ goto(x)
|
||||
}
|
||||
when(TestStateTimeout, stateTimeout = 500 millis) {
|
||||
case Ev(StateTimeout) ⇒ goto(Initial)
|
||||
case Ev(Cancel) ⇒ goto(Initial) replying (Cancel)
|
||||
case Event(StateTimeout, _) ⇒ goto(Initial)
|
||||
case Event(Cancel, _) ⇒ goto(Initial) replying (Cancel)
|
||||
}
|
||||
when(TestSingleTimer) {
|
||||
case Ev(Tick) ⇒
|
||||
case Event(Tick, _) ⇒
|
||||
tester ! Tick
|
||||
goto(Initial)
|
||||
}
|
||||
when(TestCancelTimer) {
|
||||
case Ev(Tick) ⇒
|
||||
case Event(Tick, _) ⇒
|
||||
setTimer("hallo", Tock, 1 milli, false)
|
||||
TestKit.awaitCond(context.asInstanceOf[ActorCell].mailbox.hasMessages, 1 second)
|
||||
cancelTimer("hallo")
|
||||
sender ! Tick
|
||||
setTimer("hallo", Tock, 500 millis, false)
|
||||
stay
|
||||
case Ev(Tock) ⇒
|
||||
case Event(Tock, _) ⇒
|
||||
tester ! Tock
|
||||
stay
|
||||
case Ev(Cancel) ⇒
|
||||
case Event(Cancel, _) ⇒
|
||||
cancelTimer("hallo")
|
||||
goto(Initial)
|
||||
}
|
||||
|
|
@ -206,29 +206,29 @@ object FSMTimingSpec {
|
|||
}
|
||||
when(TestCancelStateTimerInNamedTimerMessage) {
|
||||
// FSM is suspended after processing this message and resumed 500ms later
|
||||
case Ev(Tick) ⇒
|
||||
case Event(Tick, _) ⇒
|
||||
suspend(self)
|
||||
setTimer("named", Tock, 1 millis, false)
|
||||
TestKit.awaitCond(context.asInstanceOf[ActorCell].mailbox.hasMessages, 1 second)
|
||||
stay forMax (1 millis) replying Tick
|
||||
case Ev(Tock) ⇒
|
||||
case Event(Tock, _) ⇒
|
||||
goto(TestCancelStateTimerInNamedTimerMessage2)
|
||||
}
|
||||
when(TestCancelStateTimerInNamedTimerMessage2) {
|
||||
case Ev(StateTimeout) ⇒
|
||||
case Event(StateTimeout, _) ⇒
|
||||
goto(Initial)
|
||||
case Ev(Cancel) ⇒
|
||||
case Event(Cancel, _) ⇒
|
||||
goto(Initial) replying Cancel
|
||||
}
|
||||
when(TestUnhandled) {
|
||||
case Ev(SetHandler) ⇒
|
||||
case Event(SetHandler, _) ⇒
|
||||
whenUnhandled {
|
||||
case Ev(Tick) ⇒
|
||||
case Event(Tick, _) ⇒
|
||||
tester ! Unhandled(Tick)
|
||||
stay
|
||||
}
|
||||
stay
|
||||
case Ev(Cancel) ⇒
|
||||
case Event(Cancel, _) ⇒
|
||||
whenUnhandled(NullFunction)
|
||||
goto(Initial)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ package akka.actor
|
|||
|
||||
import akka.testkit._
|
||||
import akka.util.duration._
|
||||
import FSM._
|
||||
import akka.util.Duration
|
||||
|
||||
object FSMTransitionSpec {
|
||||
|
|
@ -17,13 +16,13 @@ object FSMTransitionSpec {
|
|||
class MyFSM(target: ActorRef) extends Actor with FSM[Int, Unit] {
|
||||
startWith(0, Unit)
|
||||
when(0) {
|
||||
case Ev("tick") ⇒ goto(1)
|
||||
case Event("tick", _) ⇒ goto(1)
|
||||
}
|
||||
when(1) {
|
||||
case Ev("tick") ⇒ goto(0)
|
||||
case Event("tick", _) ⇒ goto(0)
|
||||
}
|
||||
whenUnhandled {
|
||||
case Ev("reply") ⇒ stay replying "reply"
|
||||
case Event("reply", _) ⇒ stay replying "reply"
|
||||
}
|
||||
initialize
|
||||
override def preRestart(reason: Throwable, msg: Option[Any]) { target ! "restarted" }
|
||||
|
|
@ -32,10 +31,10 @@ object FSMTransitionSpec {
|
|||
class OtherFSM(target: ActorRef) extends Actor with FSM[Int, Int] {
|
||||
startWith(0, 0)
|
||||
when(0) {
|
||||
case Ev("tick") ⇒ goto(1) using (1)
|
||||
case Event("tick", _) ⇒ goto(1) using (1)
|
||||
}
|
||||
when(1) {
|
||||
case Ev(_) ⇒ stay
|
||||
case _ ⇒ stay
|
||||
}
|
||||
onTransition {
|
||||
case 0 -> 1 ⇒ target ! ((stateData, nextStateData))
|
||||
|
|
@ -56,6 +55,8 @@ class FSMTransitionSpec extends AkkaSpec with ImplicitSender {
|
|||
"A FSM transition notifier" must {
|
||||
|
||||
"notify listeners" in {
|
||||
import FSM.{ SubscribeTransitionCallBack, CurrentState, Transition }
|
||||
|
||||
val fsm = system.actorOf(Props(new MyFSM(testActor)))
|
||||
within(1 second) {
|
||||
fsm ! SubscribeTransitionCallBack(testActor)
|
||||
|
|
@ -77,8 +78,8 @@ class FSMTransitionSpec extends AkkaSpec with ImplicitSender {
|
|||
}))
|
||||
|
||||
within(300 millis) {
|
||||
fsm ! SubscribeTransitionCallBack(forward)
|
||||
expectMsg(CurrentState(fsm, 0))
|
||||
fsm ! FSM.SubscribeTransitionCallBack(forward)
|
||||
expectMsg(FSM.CurrentState(fsm, 0))
|
||||
system.stop(forward)
|
||||
fsm ! "tick"
|
||||
expectNoMsg
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.omg.CORBA.portable.IDLEntity;
|
||||
|
||||
import com.eaio.util.lang.Hex;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,86 +0,0 @@
|
|||
package com.eaio.uuid;
|
||||
|
||||
|
||||
/**
|
||||
* com/eaio/uuid/UUIDHelper.java .
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.1"
|
||||
* from uuid.idl
|
||||
* Sonntag, 7. März 2004 21.35 Uhr CET
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The UUID struct.
|
||||
*/
|
||||
abstract public class UUIDHelper
|
||||
{
|
||||
private static String _id = "IDL:com/eaio/uuid/UUID:1.0";
|
||||
|
||||
public static void insert (org.omg.CORBA.Any a, com.eaio.uuid.UUID that)
|
||||
{
|
||||
org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
|
||||
a.type (type ());
|
||||
write (out, that);
|
||||
a.read_value (out.create_input_stream (), type ());
|
||||
}
|
||||
|
||||
public static com.eaio.uuid.UUID extract (org.omg.CORBA.Any a)
|
||||
{
|
||||
return read (a.create_input_stream ());
|
||||
}
|
||||
|
||||
private static org.omg.CORBA.TypeCode __typeCode = null;
|
||||
private static boolean __active = false;
|
||||
synchronized public static org.omg.CORBA.TypeCode type ()
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
synchronized (org.omg.CORBA.TypeCode.class)
|
||||
{
|
||||
if (__typeCode == null)
|
||||
{
|
||||
if (__active)
|
||||
{
|
||||
return org.omg.CORBA.ORB.init().create_recursive_tc ( _id );
|
||||
}
|
||||
__active = true;
|
||||
org.omg.CORBA.StructMember[] _members0 = new org.omg.CORBA.StructMember [2];
|
||||
org.omg.CORBA.TypeCode _tcOf_members0 = null;
|
||||
_tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_longlong);
|
||||
_members0[0] = new org.omg.CORBA.StructMember (
|
||||
"time",
|
||||
_tcOf_members0,
|
||||
null);
|
||||
_tcOf_members0 = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind.tk_longlong);
|
||||
_members0[1] = new org.omg.CORBA.StructMember (
|
||||
"clockSeqAndNode",
|
||||
_tcOf_members0,
|
||||
null);
|
||||
__typeCode = org.omg.CORBA.ORB.init ().create_struct_tc (com.eaio.uuid.UUIDHelper.id (), "UUID", _members0);
|
||||
__active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return __typeCode;
|
||||
}
|
||||
|
||||
public static String id ()
|
||||
{
|
||||
return _id;
|
||||
}
|
||||
|
||||
public static com.eaio.uuid.UUID read (org.omg.CORBA.portable.InputStream istream)
|
||||
{
|
||||
com.eaio.uuid.UUID value = new com.eaio.uuid.UUID ();
|
||||
value.time = istream.read_longlong ();
|
||||
value.clockSeqAndNode = istream.read_longlong ();
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void write (org.omg.CORBA.portable.OutputStream ostream, com.eaio.uuid.UUID value)
|
||||
{
|
||||
ostream.write_longlong (value.time);
|
||||
ostream.write_longlong (value.clockSeqAndNode);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
package com.eaio.uuid;
|
||||
|
||||
/**
|
||||
* com/eaio/uuid/UUIDHolder.java .
|
||||
* Generated by the IDL-to-Java compiler (portable), version "3.1"
|
||||
* from uuid.idl
|
||||
* Sonntag, 7. März 2004 21.35 Uhr CET
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The UUID struct.
|
||||
*/
|
||||
public final class UUIDHolder implements org.omg.CORBA.portable.Streamable
|
||||
{
|
||||
public com.eaio.uuid.UUID value = null;
|
||||
|
||||
public UUIDHolder ()
|
||||
{
|
||||
}
|
||||
|
||||
public UUIDHolder (com.eaio.uuid.UUID initialValue)
|
||||
{
|
||||
value = initialValue;
|
||||
}
|
||||
|
||||
public void _read (org.omg.CORBA.portable.InputStream i)
|
||||
{
|
||||
value = com.eaio.uuid.UUIDHelper.read (i);
|
||||
}
|
||||
|
||||
public void _write (org.omg.CORBA.portable.OutputStream o)
|
||||
{
|
||||
com.eaio.uuid.UUIDHelper.write (o, value);
|
||||
}
|
||||
|
||||
public org.omg.CORBA.TypeCode _type ()
|
||||
{
|
||||
return com.eaio.uuid.UUIDHelper.type ();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -48,6 +48,14 @@ object FSM {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This extractor is just convenience for matching a (S, S) pair, including a
|
||||
* reminder what the new state is.
|
||||
*/
|
||||
object -> {
|
||||
def unapply[S](in: (S, S)) = Some(in)
|
||||
}
|
||||
|
||||
case class LogEntry[S, D](stateName: S, stateData: D, event: Any)
|
||||
|
||||
case class State[S, D](stateName: S, stateData: D, timeout: Option[Duration] = None, stopReason: Option[Reason] = None, replies: List[Any] = Nil) {
|
||||
|
|
@ -174,6 +182,10 @@ trait FSM[S, D] extends Listeners {
|
|||
type Timeout = Option[Duration]
|
||||
type TransitionHandler = PartialFunction[(S, S), Unit]
|
||||
|
||||
// “import” so that it is visible without an import
|
||||
val -> = FSM.->
|
||||
val StateTimeout = FSM.StateTimeout
|
||||
|
||||
val log = Logging(context.system, this)
|
||||
|
||||
/**
|
||||
|
|
@ -284,14 +296,6 @@ trait FSM[S, D] extends Listeners {
|
|||
*/
|
||||
protected final def setStateTimeout(state: S, timeout: Timeout): Unit = stateTimeouts(state) = timeout
|
||||
|
||||
/**
|
||||
* This extractor is just convenience for matching a (S, S) pair, including a
|
||||
* reminder what the new state is.
|
||||
*/
|
||||
object -> {
|
||||
def unapply[S](in: (S, S)) = Some(in)
|
||||
}
|
||||
|
||||
/**
|
||||
* Set handler which is called upon each state transition, i.e. not when
|
||||
* staying in the same state. This may use the pair extractor defined in the
|
||||
|
|
@ -533,9 +537,6 @@ trait FSM[S, D] extends Listeners {
|
|||
}
|
||||
|
||||
case class Event(event: Any, stateData: D)
|
||||
object Ev {
|
||||
def unapply[D](e: Event): Option[Any] = Some(e.event)
|
||||
}
|
||||
|
||||
case class StopEvent[S, D](reason: Reason, currentState: S, stateData: D)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,10 +89,10 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
val fsm = TestFSMRef(new Actor with FSM[Int, String] {
|
||||
startWith(1, "")
|
||||
when(1) {
|
||||
case Ev("go") ⇒ goto(2) using "go"
|
||||
case Event("go", _) ⇒ goto(2) using "go"
|
||||
}
|
||||
when(2) {
|
||||
case Ev("back") ⇒ goto(1) using "back"
|
||||
case Event("back", _) ⇒ goto(1) using "back"
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ demonstrated below:
|
|||
.. code-block:: scala
|
||||
|
||||
when(Idle) {
|
||||
case Ev(Start(msg)) => // convenience extractor when state data not needed
|
||||
case Event(Start(msg), _) =>
|
||||
goto(Timer) using (msg, sender)
|
||||
}
|
||||
|
||||
|
|
@ -188,9 +188,8 @@ demonstrated below:
|
|||
goto(Idle)
|
||||
}
|
||||
|
||||
The :class:`Event(msg, data)` case class may be used directly in the pattern as
|
||||
shown in state Idle, or you may use the extractor :obj:`Ev(msg)` when the state
|
||||
data are not needed.
|
||||
The :class:`Event(msg: Any, data: D)` case class is parameterized with the data
|
||||
type held by the FSM for convenient pattern matching.
|
||||
|
||||
Defining the Initial State
|
||||
--------------------------
|
||||
|
|
@ -216,7 +215,7 @@ do something else in this case you can specify that with
|
|||
case Event(x : X, data) =>
|
||||
log.info(this, "Received unhandled event: " + x)
|
||||
stay
|
||||
case Ev(msg) =>
|
||||
case Event(msg, _) =>
|
||||
log.warn(this, "Received unknown event: " + x)
|
||||
goto(Error)
|
||||
}
|
||||
|
|
@ -259,7 +258,7 @@ All modifier can be chained to achieve a nice and concise description:
|
|||
.. code-block:: scala
|
||||
|
||||
when(State) {
|
||||
case Ev(msg) =>
|
||||
case Event(msg, _) =>
|
||||
goto(Processing) using (msg) forMax (5 seconds) replying (WillDo)
|
||||
}
|
||||
|
||||
|
|
@ -396,7 +395,7 @@ state data which is available during termination handling.
|
|||
.. code-block:: scala
|
||||
|
||||
when(A) {
|
||||
case Ev(Stop) =>
|
||||
case Event(Stop, _) =>
|
||||
doCleanup()
|
||||
stop()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class TestActorRef[T <: Actor](
|
|||
_supervisor.path / name,
|
||||
false) {
|
||||
|
||||
private case object InternalGetActor extends AutoReceivedMessage
|
||||
import TestActorRef.InternalGetActor
|
||||
|
||||
override def newActorCell(
|
||||
system: ActorSystemImpl,
|
||||
|
|
@ -98,6 +98,8 @@ class TestActorRef[T <: Actor](
|
|||
|
||||
object TestActorRef {
|
||||
|
||||
private case object InternalGetActor extends AutoReceivedMessage
|
||||
|
||||
private val number = new AtomicLong
|
||||
private[testkit] def randomName: String = {
|
||||
val l = number.getAndIncrement()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
|
||||
package akka.testkit;
|
||||
|
||||
import org.junit.Test;
|
||||
import akka.actor.Props;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestActorRefJavaSpec {
|
||||
|
||||
@Test
|
||||
public void shouldBeAbleToUseApply() {
|
||||
//Just a dummy call to make sure it compiles
|
||||
TestActorRef ref = TestActorRef.apply(new Props(), null);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,19 +12,17 @@ import akka.util.duration._
|
|||
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
|
||||
class TestFSMRefSpec extends AkkaSpec {
|
||||
|
||||
import FSM._
|
||||
|
||||
"A TestFSMRef" must {
|
||||
|
||||
"allow access to state data" in {
|
||||
val fsm = TestFSMRef(new Actor with FSM[Int, String] {
|
||||
startWith(1, "")
|
||||
when(1) {
|
||||
case Ev("go") ⇒ goto(2) using "go"
|
||||
case Ev(StateTimeout) ⇒ goto(2) using "timeout"
|
||||
case Event("go", _) ⇒ goto(2) using "go"
|
||||
case Event(StateTimeout, _) ⇒ goto(2) using "timeout"
|
||||
}
|
||||
when(2) {
|
||||
case Ev("back") ⇒ goto(1) using "back"
|
||||
case Event("back", _) ⇒ goto(1) using "back"
|
||||
}
|
||||
}, "test-fsm-ref-1")
|
||||
fsm.stateName must be(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue