File tree 2 files changed +15
-7
lines changed
chapter04/src/test/scala/com/reactivedesignpatterns/chapter4
2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,20 @@ import akka.actor.SupervisorStrategy.Stop
6
6
import akka .testkit .TestProbe
7
7
8
8
class FailureParentSpec extends WordSpec with Matchers with BeforeAndAfterAll {
9
- " Using a FailureParent" must {
9
+ implicit val system = ActorSystem ()
10
+
11
+ " Using a FailureParent" must {
10
12
" Result in failures being collected and returned" in {
11
- implicit val system = ActorSystem ()
12
13
val failures = TestProbe ()
13
14
val failureParent = system.actorOf(Props (new FailureParent (failures.ref)))
14
15
failureParent ! TestFailureParentMessage
15
16
failures.expectMsgType[NullPointerException ]
16
17
}
17
18
}
19
+
20
+ override def afterAll (): Unit = {
21
+ system.shutdown()
22
+ }
18
23
}
19
24
20
25
case object TestFailureParentMessage
Original file line number Diff line number Diff line change @@ -6,18 +6,21 @@ import akka.actor.SupervisorStrategy.Restart
6
6
import akka .testkit .TestProbe
7
7
8
8
class StepParentSpec extends WordSpec with Matchers with BeforeAndAfterAll {
9
+ implicit val system = ActorSystem ()
10
+
9
11
" An actor that throws an exception" must {
10
12
" Result in the supervisor returning a reference to that actor" in {
11
- implicit val system = ActorSystem ()
12
13
val testProbe = TestProbe ()
13
14
val parent = system.actorOf(Props [StepParent ], " stepParent" )
14
- parent.tell(Props [MyActor ], testProbe.ref)
15
+ parent.tell(Props [MyStepParentActor ], testProbe.ref)
15
16
val child = testProbe.expectMsgType[ActorRef ]
16
17
}
17
18
}
18
- }
19
19
20
- case object TestMessage
20
+ override def afterAll (): Unit = {
21
+ system.shutdown()
22
+ }
23
+ }
21
24
22
25
class StepParent extends Actor {
23
26
override val supervisorStrategy = OneForOneStrategy () {
@@ -29,7 +32,7 @@ class StepParent extends Actor {
29
32
}
30
33
}
31
34
32
- class MyActor extends Actor {
35
+ class MyStepParentActor extends Actor {
33
36
def receive = {
34
37
case _ => throw new NullPointerException
35
38
}
You can’t perform that action at this time.
0 commit comments