File tree Expand file tree Collapse file tree
chapter04/src/test/scala/com/reactivedesignpatterns/chapter4 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,15 +6,20 @@ import akka.actor.SupervisorStrategy.Stop
66import akka .testkit .TestProbe
77
88class FailureParentSpec extends WordSpec with Matchers with BeforeAndAfterAll {
9- " Using a FailureParent" must {
9+ implicit val system = ActorSystem ()
10+
11+ " Using a FailureParent" must {
1012 " Result in failures being collected and returned" in {
11- implicit val system = ActorSystem ()
1213 val failures = TestProbe ()
1314 val failureParent = system.actorOf(Props (new FailureParent (failures.ref)))
1415 failureParent ! TestFailureParentMessage
1516 failures.expectMsgType[NullPointerException ]
1617 }
1718 }
19+
20+ override def afterAll (): Unit = {
21+ system.shutdown()
22+ }
1823}
1924
2025case object TestFailureParentMessage
Original file line number Diff line number Diff line change @@ -6,18 +6,21 @@ import akka.actor.SupervisorStrategy.Restart
66import akka .testkit .TestProbe
77
88class StepParentSpec extends WordSpec with Matchers with BeforeAndAfterAll {
9+ implicit val system = ActorSystem ()
10+
911 " An actor that throws an exception" must {
1012 " Result in the supervisor returning a reference to that actor" in {
11- implicit val system = ActorSystem ()
1213 val testProbe = TestProbe ()
1314 val parent = system.actorOf(Props [StepParent ], " stepParent" )
14- parent.tell(Props [MyActor ], testProbe.ref)
15+ parent.tell(Props [MyStepParentActor ], testProbe.ref)
1516 val child = testProbe.expectMsgType[ActorRef ]
1617 }
1718 }
18- }
1919
20- case object TestMessage
20+ override def afterAll (): Unit = {
21+ system.shutdown()
22+ }
23+ }
2124
2225class StepParent extends Actor {
2326 override val supervisorStrategy = OneForOneStrategy () {
@@ -29,7 +32,7 @@ class StepParent extends Actor {
2932 }
3033}
3134
32- class MyActor extends Actor {
35+ class MyStepParentActor extends Actor {
3336 def receive = {
3437 case _ => throw new NullPointerException
3538 }
You can’t perform that action at this time.
0 commit comments