add back TestProbe.reply, see #2172
This commit is contained in:
parent
de59444795
commit
df479a0bf0
2 changed files with 13 additions and 12 deletions
|
|
@ -210,7 +210,7 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
val probe = TestProbe()
|
||||
val future = probe.ref ? "hello"
|
||||
probe.expectMsg(0 millis, "hello") // TestActor runs on CallingThreadDispatcher
|
||||
probe.sender ! "world"
|
||||
probe.reply("world")
|
||||
assert(future.isCompleted && future.value == Some(Right("world")))
|
||||
//#test-probe-reply
|
||||
}
|
||||
|
|
@ -264,7 +264,7 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
|||
//#put-your-test-code-here
|
||||
val probe = TestProbe()
|
||||
probe.send(testActor, "hello")
|
||||
try expectMsg("hello") catch { case NonFatal(e) => system.shutdown(); throw e }
|
||||
try expectMsg("hello") catch { case NonFatal(e) ⇒ system.shutdown(); throw e }
|
||||
//#put-your-test-code-here
|
||||
|
||||
system.shutdown()
|
||||
|
|
|
|||
|
|
@ -642,22 +642,23 @@ class TestProbe(_application: ActorSystem) extends TestKit(_application) {
|
|||
* Replies will be available for inspection with all of TestKit's assertion
|
||||
* methods.
|
||||
*/
|
||||
def send(actor: ActorRef, msg: AnyRef) = {
|
||||
actor.!(msg)(testActor)
|
||||
}
|
||||
def send(actor: ActorRef, msg: Any): Unit = actor.!(msg)(testActor)
|
||||
|
||||
/**
|
||||
* Forward this message as if in the TestActor's receive method with self.forward.
|
||||
*/
|
||||
def forward(actor: ActorRef, msg: AnyRef = lastMessage.msg) {
|
||||
actor.!(msg)(lastMessage.sender)
|
||||
}
|
||||
def forward(actor: ActorRef, msg: Any = lastMessage.msg): Unit = actor.!(msg)(lastMessage.sender)
|
||||
|
||||
/**
|
||||
* Get sender of last received message.
|
||||
*/
|
||||
def sender = lastMessage.sender
|
||||
|
||||
/**
|
||||
* Send message to the sender of the last dequeued message.
|
||||
*/
|
||||
def reply(msg: Any): Unit = sender.!(msg)(ref)
|
||||
|
||||
}
|
||||
|
||||
object TestProbe {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue