playframework - Testing play controller's interaction with an akka actor -
my play application uses akka actor handle long running computation:
class mycontroller(myactor : actorref) extends controller{ def dostuff = action { implicit request => val response : future[any] = myactor ? dostuff async{ response.map{ str : string => ok(str) } } } }
i trying test things working properly. have separate tests checking actor behaves , want check controller sends right msgs actor. current approach kind of this:
class mycontrollerspec extends specification{ "mycontroller" should { object dummyactor extends actor{ def receive = { case _ => () } } "do stuff properly" >> { val probe = testprobe()(akka.system) val test = new controllers.mycontroller(akka.system.actorof(props(dummyactor)) val result = test.dostuff(fakerequest()) probe.expectmsg(somemsg) } } }
the controller send message passed in actor when dostuff action called. trying verify right msg sent.
i think test.dostuff run synchronously , times out when dummy actor doesn't send anything. expectmsg doesn't start until after dostuff call returns , somemsg sent. how can solve problem?
isn't want pass probe controller rather dummy actor implementation, how sent probe if not?
Comments
Post a Comment