Renaming TestActorRef.apply to receive, in order to get forwarders generated & improve Java API
This commit is contained in:
parent
97280ffeed
commit
19347dadbc
4 changed files with 7 additions and 7 deletions
|
|
@ -132,7 +132,7 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
||||||
import akka.testkit.TestActorRef
|
import akka.testkit.TestActorRef
|
||||||
system.eventStream.subscribe(testActor, classOf[UnhandledMessage])
|
system.eventStream.subscribe(testActor, classOf[UnhandledMessage])
|
||||||
val ref = TestActorRef[MyActor]
|
val ref = TestActorRef[MyActor]
|
||||||
ref(Unknown)
|
ref.receive(Unknown)
|
||||||
expectMsg(1 second, UnhandledMessage(Unknown, system.deadLetters, ref))
|
expectMsg(1 second, UnhandledMessage(Unknown, system.deadLetters, ref))
|
||||||
//#test-unhandled
|
//#test-unhandled
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +146,7 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
|
||||||
case boom ⇒ throw new IllegalArgumentException("boom")
|
case boom ⇒ throw new IllegalArgumentException("boom")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
intercept[IllegalArgumentException] { actorRef("hello") }
|
intercept[IllegalArgumentException] { actorRef.receive("hello") }
|
||||||
//#test-expecting-exceptions
|
//#test-expecting-exceptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ Expecting Exceptions
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
Testing that an expected exception is thrown while processing a message sent to
|
Testing that an expected exception is thrown while processing a message sent to
|
||||||
the actor under test can be done by using a :class:`TestActorRef` :meth:`apply` based
|
the actor under test can be done by using a :class:`TestActorRef` :meth:`receive` based
|
||||||
invocation:
|
invocation:
|
||||||
|
|
||||||
.. includecode:: code/akka/docs/testkit/TestkitDocSpec.scala#test-expecting-exceptions
|
.. includecode:: code/akka/docs/testkit/TestkitDocSpec.scala#test-expecting-exceptions
|
||||||
|
|
@ -144,7 +144,7 @@ The Way In-Between
|
||||||
If you want to test the actor behavior, including hotswapping, but without
|
If you want to test the actor behavior, including hotswapping, but without
|
||||||
involving a dispatcher and without having the :class:`TestActorRef` swallow
|
involving a dispatcher and without having the :class:`TestActorRef` swallow
|
||||||
any thrown exceptions, then there is another mode available for you: just use
|
any thrown exceptions, then there is another mode available for you: just use
|
||||||
the :meth:`apply` method :class:`TestActorRef`, which will be forwarded to the
|
the :meth:`receive` method :class:`TestActorRef`, which will be forwarded to the
|
||||||
underlying actor:
|
underlying actor:
|
||||||
|
|
||||||
.. includecode:: code/akka/docs/testkit/TestkitDocSpec.scala#test-unhandled
|
.. includecode:: code/akka/docs/testkit/TestkitDocSpec.scala#test-unhandled
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class TestActorRef[T <: Actor](
|
||||||
* thrown will be available to you, while still being able to use
|
* thrown will be available to you, while still being able to use
|
||||||
* become/unbecome.
|
* become/unbecome.
|
||||||
*/
|
*/
|
||||||
def apply(o: Any) { underlyingActor.apply(o) }
|
def receive(o: Any) { underlyingActor.apply(o) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve reference to the underlying actor, where the static type matches the factory used inside the
|
* Retrieve reference to the underlying actor, where the static type matches the factory used inside the
|
||||||
|
|
|
||||||
|
|
@ -224,9 +224,9 @@ class TestActorRefSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTime
|
||||||
a.underlying.dispatcher.getClass must be(classOf[CallingThreadDispatcher])
|
a.underlying.dispatcher.getClass must be(classOf[CallingThreadDispatcher])
|
||||||
}
|
}
|
||||||
|
|
||||||
"proxy apply for the underlying actor" in {
|
"proxy receive for the underlying actor" in {
|
||||||
val ref = TestActorRef[WorkerActor]
|
val ref = TestActorRef[WorkerActor]
|
||||||
ref("work")
|
ref.receive("work")
|
||||||
ref.isTerminated must be(true)
|
ref.isTerminated must be(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue