parent
918b556b0a
commit
d84266e357
2 changed files with 33 additions and 1 deletions
|
|
@ -29,5 +29,36 @@ final class OnSignalSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike
|
|||
spawn[Nothing](behavior)
|
||||
probe.expectMessage(Done)
|
||||
}
|
||||
|
||||
def stopper(probe: TestProbe[Done]) = Behaviors
|
||||
.receiveMessage[String] {
|
||||
case "stop" =>
|
||||
println("Stopping")
|
||||
Behaviors.stopped
|
||||
}
|
||||
.receiveSignal {
|
||||
case (_, PostStop) =>
|
||||
println("Post stop called")
|
||||
probe.ref ! Done
|
||||
Behaviors.same
|
||||
}
|
||||
"execute post stop" in {
|
||||
val probe = createTestProbe[Done]("post-stop-child")
|
||||
val stopperRef = spawn(stopper(probe))
|
||||
stopperRef ! "stop"
|
||||
probe.expectMessage(Done)
|
||||
|
||||
}
|
||||
|
||||
"post stop for guardian behavior" in {
|
||||
val probe = createTestProbe[Done]("post-stop-probe")
|
||||
val system = ActorSystem(stopper(probe), "work")
|
||||
try {
|
||||
system ! "stop"
|
||||
probe.expectMessage(Done)
|
||||
} finally {
|
||||
system.terminate()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ private[akka] object GuardianStartupBehavior {
|
|||
next
|
||||
else {
|
||||
ctx.asScala.system.terminate()
|
||||
Behaviors.ignore
|
||||
// return next so that the adapter can call post stop on the previous behavior
|
||||
next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue