Skip to content

Commit dfd9b35

Browse files
committed
Added shutdown
1 parent da09d15 commit dfd9b35

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

chapter04/src/test/scala/com/reactivedesignpatterns/chapter4/FailureParentSpec.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@ import akka.actor.SupervisorStrategy.Stop
66
import akka.testkit.TestProbe
77

88
class 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

2025
case object TestFailureParentMessage

chapter04/src/test/scala/com/reactivedesignpatterns/chapter4/StepParentSpec.scala

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ import akka.actor.SupervisorStrategy.Restart
66
import akka.testkit.TestProbe
77

88
class 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

2225
class 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
}

0 commit comments

Comments
 (0)