Renaming TestActorRef.apply to receive, in order to get forwarders generated & improve Java API

This commit is contained in:
Viktor Klang 2012-01-19 15:49:44 +01:00
parent 97280ffeed
commit 19347dadbc
4 changed files with 7 additions and 7 deletions

View file

@ -132,7 +132,7 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
import akka.testkit.TestActorRef
system.eventStream.subscribe(testActor, classOf[UnhandledMessage])
val ref = TestActorRef[MyActor]
ref(Unknown)
ref.receive(Unknown)
expectMsg(1 second, UnhandledMessage(Unknown, system.deadLetters, ref))
//#test-unhandled
}
@ -146,7 +146,7 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
case boom throw new IllegalArgumentException("boom")
}
})
intercept[IllegalArgumentException] { actorRef("hello") }
intercept[IllegalArgumentException] { actorRef.receive("hello") }
//#test-expecting-exceptions
}

View file

@ -75,7 +75,7 @@ Expecting Exceptions
--------------------
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:
.. 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
involving a dispatcher and without having the :class:`TestActorRef` swallow
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:
.. includecode:: code/akka/docs/testkit/TestkitDocSpec.scala#test-unhandled

View file

@ -58,7 +58,7 @@ class TestActorRef[T <: Actor](
* thrown will be available to you, while still being able to use
* 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

View file

@ -224,9 +224,9 @@ class TestActorRefSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTime
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]
ref("work")
ref.receive("work")
ref.isTerminated must be(true)
}