proxy isDefinedAt/apply through TestActorRef
This commit is contained in:
parent
4868f726c5
commit
b6446f50dd
2 changed files with 26 additions and 2 deletions
|
|
@ -18,6 +18,18 @@ class TestActorRef[T <: Actor](factory: () => T) extends LocalActorRef(factory,
|
|||
dispatcher = CallingThreadDispatcher.global
|
||||
receiveTimeout = None
|
||||
|
||||
/**
|
||||
* Query actor's current receive behavior.
|
||||
*/
|
||||
override def isDefinedAt(o : Any) = actor.isDefinedAt(o)
|
||||
|
||||
/**
|
||||
* Directly inject messages into actor receive behavior. Any exceptions
|
||||
* thrown will be available to you, while still being able to use
|
||||
* become/unbecome and their message counterparts.
|
||||
*/
|
||||
def apply(o : Any) { actor(o) }
|
||||
|
||||
/**
|
||||
* Retrieve reference to the underlying actor, where the static type matches the factory used inside the
|
||||
* constructor. Beware that this reference is discarded by the ActorRef upon restarting the actor (should this
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
|
|||
override def preRestart(reason: Throwable) { counter -= 1 }
|
||||
override def postRestart(reason: Throwable) { counter -= 1 }
|
||||
}).start()
|
||||
self.dispatcher = CallingThreadDispatcher.global
|
||||
self link ref
|
||||
def receiveT = { case "sendKill" => ref ! Kill }
|
||||
}).start()
|
||||
|
|
@ -230,6 +231,17 @@ class TestActorRefSpec extends WordSpec with MustMatchers with BeforeAndAfterEac
|
|||
EventHandler.removeListener(log)
|
||||
}
|
||||
|
||||
"proxy isDefinedAt/apply for the underlying actor" in {
|
||||
val ref = TestActorRef[WorkerActor].start()
|
||||
ref.isDefinedAt("work") must be (true)
|
||||
ref.isDefinedAt("sleep") must be (false)
|
||||
val ch = Future.channel()
|
||||
ref ! ch
|
||||
val f = ch.future
|
||||
f must be ('completed)
|
||||
f() must be ("complexReply")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private def stopLog() = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue