add TestKit.setAutoPilot, see #1807
This commit is contained in:
parent
b5826f9bd9
commit
ec15fd6cfd
3 changed files with 67 additions and 3 deletions
|
|
@ -40,6 +40,31 @@ class TestProbeSpec extends AkkaSpec with DefaultTimeout {
|
|||
probe1.expectMsg(0 millis, "world")
|
||||
}
|
||||
|
||||
"have an AutoPilot" in {
|
||||
//#autopilot
|
||||
val probe = TestProbe()
|
||||
probe.setAutoPilot(new TestActor.AutoPilot {
|
||||
def run(sender: ActorRef, msg: Any): Option[TestActor.AutoPilot] =
|
||||
msg match {
|
||||
case "stop" ⇒ None
|
||||
case x ⇒ testActor.tell(x, sender); Some(this)
|
||||
}
|
||||
})
|
||||
//#autopilot
|
||||
probe.ref ! "hallo"
|
||||
probe.ref ! "welt"
|
||||
probe.ref ! "stop"
|
||||
expectMsg("hallo")
|
||||
expectMsg("welt")
|
||||
probe.expectMsg("hallo")
|
||||
probe.expectMsg("welt")
|
||||
probe.expectMsg("stop")
|
||||
probe.ref ! "hallo"
|
||||
probe.expectMsg("hallo")
|
||||
testActor ! "end"
|
||||
expectMsg("end") // verify that "hallo" did not get through
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue