From 19347dadbc31e905d2dd1ed7338fa0c4c0f7ba39 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 19 Jan 2012 15:49:44 +0100 Subject: [PATCH] Renaming TestActorRef.apply to receive, in order to get forwarders generated & improve Java API --- akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala | 4 ++-- akka-docs/scala/testing.rst | 4 ++-- akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala | 2 +- .../src/test/scala/akka/testkit/TestActorRefSpec.scala | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala b/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala index 0678860ba9..8eaba57c8c 100644 --- a/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala +++ b/akka-docs/scala/code/akka/docs/testkit/TestkitDocSpec.scala @@ -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 } diff --git a/akka-docs/scala/testing.rst b/akka-docs/scala/testing.rst index 47157a2385..0f80342bc4 100644 --- a/akka-docs/scala/testing.rst +++ b/akka-docs/scala/testing.rst @@ -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 diff --git a/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala b/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala index eaeecf7487..85057790d2 100644 --- a/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala +++ b/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala @@ -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 diff --git a/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala b/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala index d5c9b1a151..95082304db 100644 --- a/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala +++ b/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala @@ -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) }