add test for scrapping of behaviorStack during restart

This commit is contained in:
Roland 2012-07-08 17:59:59 +02:00
parent 3c809e2420
commit f362966ee8

View file

@ -116,6 +116,30 @@ class ActorLifeCycleSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitS
expectNoMsg(1 seconds)
system.stop(supervisor)
}
"clear the behavior stack upon restart" in {
case class Become(recv: ActorContext Receive)
val a = system.actorOf(Props(new Actor {
def receive = {
case Become(beh) context.become(beh(context), discardOld = false); sender ! "ok"
case x sender ! 42
}
}))
a ! "hello"
expectMsg(42)
a ! Become(ctx {
case "fail" throw new RuntimeException("buh")
case x ctx.sender ! 43
})
expectMsg("ok")
a ! "hello"
expectMsg(43)
EventFilter[RuntimeException]("buh", occurrences = 1) intercept {
a ! "fail"
}
a ! "hello"
expectMsg(42)
}
}
}