[2.1.4] nextStateData during onTransition

89 views
Skip to first unread message

Marius Stroe

unread,
Jun 19, 2013, 11:49:24 AM6/19/13
to akka...@googlegroups.com
Hi,



It seems I can't access "nextStateData" inside "onTransition". Is it a bug or am I doing something wrong? Thank you.


Kind regards,

-- Marius

Marius Stroe

unread,
Jun 19, 2013, 1:49:17 PM6/19/13
to akka...@googlegroups.com
The output comes when running a test with specs2. The setup is:

val actorRef = TestFSMRef(spy(new FSMActor))
val fsm = actorRef.underlyingActor.asInstanceOf[FSMActor]
doReturn(testActor).when(fsm).child("childName")

Another issue is that "actorRef.underlyingActor" returns "scala.Nothing" and I can't spy the underlying actor. Nevertheless, spying the underlying non-FSM actor works with "TestActorRef". I would expect the TestFSMRef to work exactly like TestActorRef. I've created another thread for this issue.


Kind regards,

-- Marius

Roland Kuhn

unread,
Jun 22, 2013, 2:55:35 AM6/22/13
to akka...@googlegroups.com
Hi Marius,

while I don’t see what’s wrong in your case (or whether you have cut out too much in the code you show), here is our test case which verifies this:

  class OtherFSM(target: ActorRef) extends Actor with FSM[Int, Int] {
    startWith(0, 0)
    when(0) {
      case Event("tick", _) ⇒ goto(1) using (1)
    }
    when(1) {
      case _ ⇒ stay
    }
    onTransition {
      case 0 -> 1target ! ((stateData, nextStateData))
    }
  }

Methods like “spy” look suspicious by definition ;-)

Regards,

Roland

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



Dr. Roland Kuhn
Akka Tech Lead
Typesafe – Reactive apps on the JVM.
twitter: @rolandkuhn


Marius Stroe

unread,
Jun 22, 2013, 4:17:00 AM6/22/13
to akka...@googlegroups.com
Hi Roland,


I agree, I've seen the tests for FSMs. I wanted to use the TestFSMRef which I don't remember to be seen used in any test on Akka repository.

I think it's related to the other topic: https://groups.google.com/forum/#!topic/akka-user/_vyn98faY0w  I'll wait to give that fix a try and see what happens.


Kind regards,

--
Marius

Marius Stroe

unread,
Jun 24, 2013, 5:30:41 PM6/24/13
to akka...@googlegroups.com
It seems that nextStateData is not available using Mockito's spy().

It works with:

val actorRef = TestFSMRef(new FSMActor, "test-fsm")

but it doesn't work with:

val actorRef = TestFSMRef(spy(new FSMActor), "test-fsm")
val actorRef = TestActorRef(spy(new FSMActor), "test-fsm")

Sometimes, it can be useful to spy and stub some functions :-) Is Akka team considering this an issue? As a side note, spy() works well with TestActorRef and a normal actor.


Kind regards,

Patrik Nordwall

unread,
Jun 27, 2013, 4:43:20 AM6/27/13
to akka...@googlegroups.com
On Mon, Jun 24, 2013 at 11:30 PM, Marius Stroe <laurent...@gmail.com> wrote:
It seems that nextStateData is not available using Mockito's spy().

It works with:

val actorRef = TestFSMRef(new FSMActor, "test-fsm")

but it doesn't work with:

val actorRef = TestFSMRef(spy(new FSMActor), "test-fsm")
val actorRef = TestActorRef(spy(new FSMActor), "test-fsm")

Sometimes, it can be useful to spy and stub some functions :-) Is Akka team considering this an issue?

Mockito spy documentation comes with a lot of warnings and gotchas. I'm don't what kind of problem it introduces with TestFSMRef and it is not something we will investigate. Feel free to submit suggestion of how to make TestFSMRef spy friendly if it is of importance for you.

/Patrik



--

Patrik Nordwall
Typesafe The software stack for applications that scale
Twitter: @patriknw

Reply all
Reply to author
Forward
0 new messages