From f7d6393027d32158b09f31af7715e499c2b051c1 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Wed, 7 Dec 2011 11:10:54 +0100 Subject: [PATCH] Removed actorOf methods from AkkaSpec. See #1439 --- .../ActorFireForgetRequestReplySpec.scala | 10 ++--- .../scala/akka/actor/ActorLifeCycleSpec.scala | 6 +-- .../test/scala/akka/actor/ActorRefSpec.scala | 19 +++++---- .../scala/akka/actor/ActorTimeoutSpec.scala | 2 +- .../scala/akka/actor/DeathWatchSpec.scala | 14 +++---- .../test/scala/akka/actor/FSMActorSpec.scala | 8 ++-- .../test/scala/akka/actor/FSMTimingSpec.scala | 2 +- .../scala/akka/actor/FSMTransitionSpec.scala | 8 ++-- .../scala/akka/actor/ForwardActorSpec.scala | 2 +- .../test/scala/akka/actor/HotSwapSpec.scala | 8 ++-- .../src/test/scala/akka/actor/IOActor.scala | 26 ++++++------ .../actor/LocalActorRefProviderSpec.scala | 2 +- .../scala/akka/actor/ReceiveTimeoutSpec.scala | 10 ++--- .../akka/actor/RestartStrategySpec.scala | 10 ++--- .../test/scala/akka/actor/SchedulerSpec.scala | 12 +++--- .../akka/actor/SupervisorHierarchySpec.scala | 4 +- .../scala/akka/actor/SupervisorMiscSpec.scala | 2 +- .../scala/akka/actor/SupervisorSpec.scala | 16 +++---- .../scala/akka/actor/SupervisorTreeSpec.scala | 2 +- .../test/scala/akka/actor/Ticket669Spec.scala | 4 +- .../scala/akka/actor/TypedActorSpec.scala | 2 +- .../akka/actor/dispatch/ActorModelSpec.scala | 2 +- .../dispatch/BalancingDispatcherSpec.scala | 4 +- .../actor/dispatch/DispatcherActorSpec.scala | 12 +++--- .../actor/dispatch/DispatcherActorsSpec.scala | 4 +- .../akka/actor/dispatch/PinnedActorSpec.scala | 4 +- .../akka/actor/routing/ListenerSpec.scala | 4 +- .../test/scala/akka/dispatch/FutureSpec.scala | 42 +++++++++---------- .../dispatch/PriorityDispatcherSpec.scala | 2 +- .../test/scala/akka/event/EventBusSpec.scala | 2 +- .../scala/akka/routing/ActorPoolSpec.scala | 30 ++++++------- .../test/scala/akka/routing/RoutingSpec.scala | 34 +++++++-------- .../scala/akka/ticket/Ticket703Spec.scala | 4 +- akka-docs/scala/code/ActorDocSpec.scala | 4 +- .../actor/mailbox/DurableMailboxSpec.scala | 6 +-- .../test/scala/akka/testkit/AkkaSpec.scala | 10 +---- .../scala/akka/testkit/TestActorRefSpec.scala | 2 +- 37 files changed, 164 insertions(+), 171 deletions(-) diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala index 09112d837f..2537b996ad 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorFireForgetRequestReplySpec.scala @@ -63,16 +63,16 @@ class ActorFireForgetRequestReplySpec extends AkkaSpec with BeforeAndAfterEach w "An Actor" must { "reply to bang message using reply" in { - val replyActor = actorOf[ReplyActor] - val senderActor = actorOf(new SenderActor(replyActor)) + val replyActor = system.actorOf[ReplyActor] + val senderActor = system.actorOf(new SenderActor(replyActor)) senderActor ! "Init" state.finished.await state.s must be("Reply") } "reply to bang message using implicit sender" in { - val replyActor = actorOf[ReplyActor] - val senderActor = actorOf(new SenderActor(replyActor)) + val replyActor = system.actorOf[ReplyActor] + val senderActor = system.actorOf(new SenderActor(replyActor)) senderActor ! "InitImplicit" state.finished.await state.s must be("ReplyImplicit") @@ -80,7 +80,7 @@ class ActorFireForgetRequestReplySpec extends AkkaSpec with BeforeAndAfterEach w "should shutdown crashed temporary actor" in { filterEvents(EventFilter[Exception]("Expected exception")) { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(0)))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(0)))) val actor = (supervisor ? Props[CrashingActor]).as[ActorRef].get actor.isTerminated must be(false) actor ! "Die" diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorLifeCycleSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorLifeCycleSpec.scala index 0080efc7c4..8f3a58e5e5 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorLifeCycleSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorLifeCycleSpec.scala @@ -34,7 +34,7 @@ class ActorLifeCycleSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitS "invoke preRestart, preStart, postRestart when using OneForOneStrategy" in { filterException[ActorKilledException] { val id = newUuid().toString - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(3)))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(3)))) val gen = new AtomicInteger(0) val restarterProps = Props(new LifeCycleTestActor(testActor, id, gen) { override def preRestart(reason: Throwable, message: Option[Any]) { report("preRestart") } @@ -68,7 +68,7 @@ class ActorLifeCycleSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitS "default for preRestart and postRestart is to call postStop and preStart respectively" in { filterException[ActorKilledException] { val id = newUuid().toString - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(3)))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(3)))) val gen = new AtomicInteger(0) val restarterProps = Props(new LifeCycleTestActor(testActor, id, gen)) val restarter = (supervisor ? restarterProps).as[ActorRef].get @@ -98,7 +98,7 @@ class ActorLifeCycleSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitS "not invoke preRestart and postRestart when never restarted using OneForOneStrategy" in { val id = newUuid().toString - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(3)))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(3)))) val gen = new AtomicInteger(0) val props = Props(new LifeCycleTestActor(testActor, id, gen)) val a = (supervisor ? props).as[ActorRef].get diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorRefSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorRefSpec.scala index e5e6a77c7b..b3b8ece741 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorRefSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorRefSpec.scala @@ -135,6 +135,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { "An ActorRef" must { "not allow Actors to be created outside of an actorOf" in { + import system.actorOf intercept[akka.actor.ActorInitializationException] { new Actor { def receive = { case _ ⇒ } } } @@ -236,7 +237,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { } "be serializable using Java Serialization on local node" in { - val a = actorOf[InnerActor] + val a = system.actorOf[InnerActor] import java.io._ @@ -259,7 +260,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { } "throw an exception on deserialize if no system in scope" in { - val a = actorOf[InnerActor] + val a = system.actorOf[InnerActor] import java.io._ @@ -300,8 +301,8 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { } "support nested actorOfs" in { - val a = actorOf(new Actor { - val nested = actorOf(new Actor { def receive = { case _ ⇒ } }) + val a = system.actorOf(new Actor { + val nested = system.actorOf(new Actor { def receive = { case _ ⇒ } }) def receive = { case _ ⇒ sender ! nested } }) @@ -312,7 +313,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { } "support advanced nested actorOfs" in { - val a = actorOf(Props(new OuterActor(actorOf(Props(new InnerActor))))) + val a = system.actorOf(Props(new OuterActor(system.actorOf(Props(new InnerActor))))) val inner = (a ? "innerself").as[Any].get (a ? a).as[ActorRef].get must be(a) @@ -324,8 +325,8 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { "support reply via sender" in { val latch = new TestLatch(4) - val serverRef = actorOf(Props[ReplyActor]) - val clientRef = actorOf(Props(new SenderActor(serverRef, latch))) + val serverRef = system.actorOf(Props[ReplyActor]) + val clientRef = system.actorOf(Props(new SenderActor(serverRef, latch))) clientRef ! "complex" clientRef ! "simple" @@ -349,7 +350,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { "stop when sent a poison pill" in { val timeout = Timeout(20000) - val ref = actorOf(Props(new Actor { + val ref = system.actorOf(Props(new Actor { def receive = { case 5 ⇒ sender.tell("five") case null ⇒ sender.tell("null") @@ -370,7 +371,7 @@ class ActorRefSpec extends AkkaSpec with DefaultTimeout { filterException[ActorKilledException] { val latch = new CountDownLatch(2) - val boss = actorOf(Props(new Actor { + val boss = system.actorOf(Props(new Actor { val ref = context.actorOf( Props(new Actor { diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorTimeoutSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorTimeoutSpec.scala index e2ac25bb2b..735867bc97 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorTimeoutSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorTimeoutSpec.scala @@ -12,7 +12,7 @@ import akka.testkit.DefaultTimeout @org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner]) class ActorTimeoutSpec extends AkkaSpec with BeforeAndAfterAll with DefaultTimeout { - def actorWithTimeout(t: Timeout): ActorRef = actorOf(Props(creator = () ⇒ new Actor { + def actorWithTimeout(t: Timeout): ActorRef = system.actorOf(Props(creator = () ⇒ new Actor { def receive = { case x ⇒ } diff --git a/akka-actor-tests/src/test/scala/akka/actor/DeathWatchSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/DeathWatchSpec.scala index 46e14a2d8d..9aba8979c1 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/DeathWatchSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/DeathWatchSpec.scala @@ -11,7 +11,7 @@ import java.util.concurrent.atomic._ @org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner]) class DeathWatchSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSender with DefaultTimeout { - def startWatching(target: ActorRef) = actorOf(Props(new Actor { + def startWatching(target: ActorRef) = system.actorOf(Props(new Actor { context.watch(target) def receive = { case x ⇒ testActor forward x } })) @@ -22,7 +22,7 @@ class DeathWatchSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende } "notify with one Terminated message when an Actor is stopped" in { - val terminal = actorOf(Props(context ⇒ { case _ ⇒ })) + val terminal = system.actorOf(Props(context ⇒ { case _ ⇒ })) startWatching(terminal) testActor ! "ping" @@ -34,7 +34,7 @@ class DeathWatchSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende } "notify with all monitors with one Terminated message when an Actor is stopped" in { - val terminal = actorOf(Props(context ⇒ { case _ ⇒ })) + val terminal = system.actorOf(Props(context ⇒ { case _ ⇒ })) val monitor1, monitor2, monitor3 = startWatching(terminal) terminal ! PoisonPill @@ -49,9 +49,9 @@ class DeathWatchSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende } "notify with _current_ monitors with one Terminated message when an Actor is stopped" in { - val terminal = actorOf(Props(context ⇒ { case _ ⇒ })) + val terminal = system.actorOf(Props(context ⇒ { case _ ⇒ })) val monitor1, monitor3 = startWatching(terminal) - val monitor2 = actorOf(Props(new Actor { + val monitor2 = system.actorOf(Props(new Actor { context.watch(terminal) context.unwatch(terminal) def receive = { @@ -76,7 +76,7 @@ class DeathWatchSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende "notify with a Terminated message once when an Actor is stopped but not when restarted" in { filterException[ActorKilledException] { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(2)))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(2)))) val terminalProps = Props(context ⇒ { case x ⇒ context.sender ! x }) val terminal = (supervisor ? terminalProps).as[ActorRef].get @@ -97,7 +97,7 @@ class DeathWatchSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende "fail a monitor which does not handle Terminated()" in { filterEvents(EventFilter[ActorKilledException](), EventFilter[DeathPactException]()) { case class FF(fail: Failed) - val supervisor = actorOf(Props[Supervisor] + val supervisor = system.actorOf(Props[Supervisor] .withFaultHandler(new OneForOneStrategy(FaultHandlingStrategy.makeDecider(List(classOf[Exception])), Some(0)) { override def handleFailure(child: ActorRef, cause: Throwable, stats: ChildRestartStats, children: Iterable[ChildRestartStats]) = { testActor.tell(FF(Failed(cause)), child) diff --git a/akka-actor-tests/src/test/scala/akka/actor/FSMActorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/FSMActorSpec.scala index b73658a352..0f09c3e1d2 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/FSMActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/FSMActorSpec.scala @@ -112,9 +112,9 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im import latches._ // lock that locked after being open for 1 sec - val lock = actorOf(new Lock("33221", 1 second, latches)) + val lock = system.actorOf(new Lock("33221", 1 second, latches)) - val transitionTester = actorOf(new Actor { + val transitionTester = system.actorOf(new Actor { def receive = { case Transition(_, _, _) ⇒ transitionCallBackLatch.open case CurrentState(_, Locked) ⇒ initialStateLatch.open @@ -143,7 +143,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im val answerLatch = TestLatch() object Hello object Bye - val tester = actorOf(new Actor { + val tester = system.actorOf(new Actor { protected def receive = { case Hello ⇒ lock ! "hello" case "world" ⇒ answerLatch.open @@ -185,7 +185,7 @@ class FSMActorSpec extends AkkaSpec(Map("akka.actor.debug.fsm" -> true)) with Im case x ⇒ testActor ! x } } - val ref = actorOf(fsm) + val ref = system.actorOf(fsm) started.await ref.stop() expectMsg(1 second, fsm.StopEvent(Shutdown, 1, null)) diff --git a/akka-actor-tests/src/test/scala/akka/actor/FSMTimingSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/FSMTimingSpec.scala index 6a0cc7d3ec..85bd70248f 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/FSMTimingSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/FSMTimingSpec.scala @@ -14,7 +14,7 @@ class FSMTimingSpec extends AkkaSpec with ImplicitSender { import FSMTimingSpec._ import FSM._ - val fsm = actorOf(new StateMachine(testActor)) + val fsm = system.actorOf(new StateMachine(testActor)) fsm ! SubscribeTransitionCallBack(testActor) expectMsg(1 second, CurrentState(fsm, Initial)) diff --git a/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala index 4b17a8f144..afdf9da5eb 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/FSMTransitionSpec.scala @@ -43,7 +43,7 @@ class FSMTransitionSpec extends AkkaSpec with ImplicitSender { "A FSM transition notifier" must { "notify listeners" in { - val fsm = actorOf(new MyFSM(testActor)) + val fsm = system.actorOf(new MyFSM(testActor)) within(1 second) { fsm ! SubscribeTransitionCallBack(testActor) expectMsg(CurrentState(fsm, 0)) @@ -55,9 +55,9 @@ class FSMTransitionSpec extends AkkaSpec with ImplicitSender { } "not fail when listener goes away" in { - val forward = actorOf(new Forwarder(testActor)) - val fsm = actorOf(new MyFSM(testActor)) - val sup = actorOf(Props(new Actor { + val forward = system.actorOf(new Forwarder(testActor)) + val fsm = system.actorOf(new MyFSM(testActor)) + val sup = system.actorOf(Props(new Actor { context.watch(fsm) def receive = { case _ ⇒ } }).withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), None, None))) diff --git a/akka-actor-tests/src/test/scala/akka/actor/ForwardActorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ForwardActorSpec.scala index 2951e957dc..86af471d13 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ForwardActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ForwardActorSpec.scala @@ -35,7 +35,7 @@ class ForwardActorSpec extends AkkaSpec { "forward actor reference when invoking forward on bang" in { val latch = new TestLatch(1) - val replyTo = actorOf(new Actor { def receive = { case ExpectedMessage ⇒ latch.countDown() } }) + val replyTo = system.actorOf(new Actor { def receive = { case ExpectedMessage ⇒ latch.countDown() } }) val chain = createForwardingChain(system) diff --git a/akka-actor-tests/src/test/scala/akka/actor/HotSwapSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/HotSwapSpec.scala index f57bfe3548..19ea9c19c1 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/HotSwapSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/HotSwapSpec.scala @@ -15,7 +15,7 @@ class HotSwapSpec extends AkkaSpec { val barrier = TestBarrier(2) @volatile var _log = "" - val a = actorOf(new Actor { + val a = system.actorOf(new Actor { def receive = { case _ ⇒ _log += "default" } }) a ! HotSwap(self ⇒ { @@ -32,7 +32,7 @@ class HotSwapSpec extends AkkaSpec { val barrier = TestBarrier(2) @volatile var _log = "" - val a = actorOf(new Actor { + val a = system.actorOf(new Actor { def receive = { case "init" ⇒ _log += "init" @@ -61,7 +61,7 @@ class HotSwapSpec extends AkkaSpec { val barrier = TestBarrier(2) @volatile var _log = "" - val a = actorOf(new Actor { + val a = system.actorOf(new Actor { def receive = { case "init" ⇒ _log += "init" @@ -107,7 +107,7 @@ class HotSwapSpec extends AkkaSpec { val barrier = TestBarrier(2) @volatile var _log = "" - val a = actorOf(new Actor { + val a = system.actorOf(new Actor { def receive = { case "init" ⇒ _log += "init" diff --git a/akka-actor-tests/src/test/scala/akka/actor/IOActor.scala b/akka-actor-tests/src/test/scala/akka/actor/IOActor.scala index 15bc982eb3..8e15f5fbbe 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/IOActor.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/IOActor.scala @@ -186,10 +186,10 @@ class IOActorSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout { "an IO Actor" must { "run echo server" in { val started = TestLatch(1) - val ioManager = actorOf(new IOManager(2)) // teeny tiny buffer - val server = actorOf(new SimpleEchoServer("localhost", 8064, ioManager, started)) + val ioManager = system.actorOf(new IOManager(2)) // teeny tiny buffer + val server = system.actorOf(new SimpleEchoServer("localhost", 8064, ioManager, started)) started.await - val client = actorOf(new SimpleEchoClient("localhost", 8064, ioManager)) + val client = system.actorOf(new SimpleEchoClient("localhost", 8064, ioManager)) val f1 = client ? ByteString("Hello World!1") val f2 = client ? ByteString("Hello World!2") val f3 = client ? ByteString("Hello World!3") @@ -203,10 +203,10 @@ class IOActorSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout { "run echo server under high load" in { val started = TestLatch(1) - val ioManager = actorOf(new IOManager()) - val server = actorOf(new SimpleEchoServer("localhost", 8065, ioManager, started)) + val ioManager = system.actorOf(new IOManager()) + val server = system.actorOf(new SimpleEchoServer("localhost", 8065, ioManager, started)) started.await - val client = actorOf(new SimpleEchoClient("localhost", 8065, ioManager)) + val client = system.actorOf(new SimpleEchoClient("localhost", 8065, ioManager)) val list = List.range(0, 1000) val f = Future.traverse(list)(i ⇒ client ? ByteString(i.toString)) assert(f.get.size === 1000) @@ -217,10 +217,10 @@ class IOActorSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout { "run echo server under high load with small buffer" in { val started = TestLatch(1) - val ioManager = actorOf(new IOManager(2)) - val server = actorOf(new SimpleEchoServer("localhost", 8066, ioManager, started)) + val ioManager = system.actorOf(new IOManager(2)) + val server = system.actorOf(new SimpleEchoServer("localhost", 8066, ioManager, started)) started.await - val client = actorOf(new SimpleEchoClient("localhost", 8066, ioManager)) + val client = system.actorOf(new SimpleEchoClient("localhost", 8066, ioManager)) val list = List.range(0, 1000) val f = Future.traverse(list)(i ⇒ client ? ByteString(i.toString)) assert(f.get.size === 1000) @@ -231,11 +231,11 @@ class IOActorSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout { "run key-value store" in { val started = TestLatch(1) - val ioManager = actorOf(new IOManager(2)) // teeny tiny buffer - val server = actorOf(new KVStore("localhost", 8067, ioManager, started)) + val ioManager = system.actorOf(new IOManager(2)) // teeny tiny buffer + val server = system.actorOf(new KVStore("localhost", 8067, ioManager, started)) started.await - val client1 = actorOf(new KVClient("localhost", 8067, ioManager)) - val client2 = actorOf(new KVClient("localhost", 8067, ioManager)) + val client1 = system.actorOf(new KVClient("localhost", 8067, ioManager)) + val client2 = system.actorOf(new KVClient("localhost", 8067, ioManager)) val f1 = client1 ? (('set, "hello", ByteString("World"))) val f2 = client1 ? (('set, "test", ByteString("No one will read me"))) val f3 = client1 ? (('get, "hello")) diff --git a/akka-actor-tests/src/test/scala/akka/actor/LocalActorRefProviderSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/LocalActorRefProviderSpec.scala index b386767b26..991332871c 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/LocalActorRefProviderSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/LocalActorRefProviderSpec.scala @@ -13,7 +13,7 @@ class LocalActorRefProviderSpec extends AkkaSpec { "An LocalActorRefProvider" must { "find actor refs using actorFor" in { - val a = actorOf(Props(ctx ⇒ { case _ ⇒ })) + val a = system.actorOf(Props(ctx ⇒ { case _ ⇒ })) val b = system.actorFor(a.path) a must be === b } diff --git a/akka-actor-tests/src/test/scala/akka/actor/ReceiveTimeoutSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ReceiveTimeoutSpec.scala index f34ea05924..8981473cc2 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ReceiveTimeoutSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ReceiveTimeoutSpec.scala @@ -17,7 +17,7 @@ class ReceiveTimeoutSpec extends AkkaSpec { "get timeout" in { val timeoutLatch = TestLatch() - val timeoutActor = actorOf(new Actor { + val timeoutActor = system.actorOf(new Actor { context.receiveTimeout = Some(500 milliseconds) protected def receive = { @@ -32,7 +32,7 @@ class ReceiveTimeoutSpec extends AkkaSpec { "get timeout when swapped" in { val timeoutLatch = TestLatch() - val timeoutActor = actorOf(new Actor { + val timeoutActor = system.actorOf(new Actor { context.receiveTimeout = Some(500 milliseconds) protected def receive = { @@ -56,7 +56,7 @@ class ReceiveTimeoutSpec extends AkkaSpec { val timeoutLatch = TestLatch() case object Tick - val timeoutActor = actorOf(new Actor { + val timeoutActor = system.actorOf(new Actor { context.receiveTimeout = Some(500 milliseconds) protected def receive = { @@ -76,7 +76,7 @@ class ReceiveTimeoutSpec extends AkkaSpec { val timeoutLatch = TestLatch() case object Tick - val timeoutActor = actorOf(new Actor { + val timeoutActor = system.actorOf(new Actor { context.receiveTimeout = Some(500 milliseconds) protected def receive = { @@ -98,7 +98,7 @@ class ReceiveTimeoutSpec extends AkkaSpec { "not receive timeout message when not specified" in { val timeoutLatch = TestLatch() - val timeoutActor = actorOf(new Actor { + val timeoutActor = system.actorOf(new Actor { protected def receive = { case ReceiveTimeout ⇒ timeoutLatch.open } diff --git a/akka-actor-tests/src/test/scala/akka/actor/RestartStrategySpec.scala b/akka-actor-tests/src/test/scala/akka/actor/RestartStrategySpec.scala index 20f30c2667..f3f70a09d7 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/RestartStrategySpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/RestartStrategySpec.scala @@ -26,7 +26,7 @@ class RestartStrategySpec extends AkkaSpec with DefaultTimeout { "A RestartStrategy" must { "ensure that slave stays dead after max restarts within time range" in { - val boss = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), 2, 1000))) + val boss = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), 2, 1000))) val restartLatch = new StandardLatch val secondRestartLatch = new StandardLatch @@ -72,7 +72,7 @@ class RestartStrategySpec extends AkkaSpec with DefaultTimeout { } "ensure that slave is immortal without max restarts and time range" in { - val boss = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), None, None))) + val boss = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), None, None))) val countDownLatch = new CountDownLatch(100) @@ -94,7 +94,7 @@ class RestartStrategySpec extends AkkaSpec with DefaultTimeout { } "ensure that slave restarts after number of crashes not within time range" in { - val boss = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), 2, 500))) + val boss = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), 2, 500))) val restartLatch = new StandardLatch val secondRestartLatch = new StandardLatch @@ -151,7 +151,7 @@ class RestartStrategySpec extends AkkaSpec with DefaultTimeout { } "ensure that slave is not restarted after max retries" in { - val boss = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), Some(2), None))) + val boss = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Throwable]), Some(2), None))) val restartLatch = new StandardLatch val secondRestartLatch = new StandardLatch @@ -205,7 +205,7 @@ class RestartStrategySpec extends AkkaSpec with DefaultTimeout { val restartLatch, stopLatch, maxNoOfRestartsLatch = new StandardLatch val countDownLatch = new CountDownLatch(2) - val boss = actorOf(Props(new Actor { + val boss = system.actorOf(Props(new Actor { def receive = { case p: Props ⇒ sender ! context.watch(context.actorOf(p)) case t: Terminated ⇒ maxNoOfRestartsLatch.open diff --git a/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala index f1f8024f77..bca3a754c8 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SchedulerSpec.scala @@ -26,7 +26,7 @@ class SchedulerSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout "schedule more than once" in { case object Tick val countDownLatch = new CountDownLatch(3) - val tickActor = actorOf(new Actor { + val tickActor = system.actorOf(new Actor { def receive = { case Tick ⇒ countDownLatch.countDown() } }) // run every 50 milliseconds @@ -56,7 +56,7 @@ class SchedulerSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout "schedule once" in { case object Tick val countDownLatch = new CountDownLatch(3) - val tickActor = actorOf(new Actor { + val tickActor = system.actorOf(new Actor { def receive = { case Tick ⇒ countDownLatch.countDown() } }) @@ -81,7 +81,7 @@ class SchedulerSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout object Ping val ticks = new CountDownLatch(1) - val actor = actorOf(new Actor { + val actor = system.actorOf(new Actor { def receive = { case Ping ⇒ ticks.countDown() } }) @@ -104,7 +104,7 @@ class SchedulerSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout val restartLatch = new StandardLatch val pingLatch = new CountDownLatch(6) - val supervisor = actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, 1000))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, 1000))) val props = Props(new Actor { def receive = { case Ping ⇒ pingLatch.countDown() @@ -131,7 +131,7 @@ class SchedulerSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout case class Msg(ts: Long) - val actor = actorOf(new Actor { + val actor = system.actorOf(new Actor { def receive = { case Msg(ts) ⇒ val now = System.nanoTime @@ -154,7 +154,7 @@ class SchedulerSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeout case object Msg - val actor = actorOf(new Actor { + val actor = system.actorOf(new Actor { def receive = { case Msg ⇒ ticks.countDown() } diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala index 2bd3ae7b5e..dc45d012fd 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala @@ -30,7 +30,7 @@ class SupervisorHierarchySpec extends AkkaSpec with DefaultTimeout { "restart manager and workers in AllForOne" in { val countDown = new CountDownLatch(4) - val boss = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), None, None))) + val boss = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), None, None))) val managerProps = Props(new CountDownActor(countDown)).withFaultHandler(AllForOneStrategy(List(), None, None)) val manager = (boss ? managerProps).as[ActorRef].get @@ -51,7 +51,7 @@ class SupervisorHierarchySpec extends AkkaSpec with DefaultTimeout { "send notification to supervisor when permanent failure" in { val countDownMessages = new CountDownLatch(1) val countDownMax = new CountDownLatch(1) - val boss = actorOf(Props(new Actor { + val boss = system.actorOf(Props(new Actor { val crasher = context.watch(context.actorOf(Props(new CountDownActor(countDownMessages)))) protected def receive = { diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala index 57229de46f..6438d6eee3 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorMiscSpec.scala @@ -18,7 +18,7 @@ class SupervisorMiscSpec extends AkkaSpec with DefaultTimeout { filterEvents(EventFilter[Exception]("Kill")) { val countDownLatch = new CountDownLatch(4) - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), 3, 5000))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), 3, 5000))) val workerProps = Props(new Actor { override def postRestart(cause: Throwable) { countDownLatch.countDown() } diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala index 4dc7dc8e6d..fdd87a2ba4 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorSpec.scala @@ -76,42 +76,42 @@ class SupervisorSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende private def child(supervisor: ActorRef, props: Props): ActorRef = (supervisor ? props).as[ActorRef].get def temporaryActorAllForOne = { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), Some(0)))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), Some(0)))) val temporaryActor = child(supervisor, Props(new PingPongActor(testActor))) (temporaryActor, supervisor) } def singleActorAllForOne = { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) val pingpong = child(supervisor, Props(new PingPongActor(testActor))) (pingpong, supervisor) } def singleActorOneForOne = { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) val pingpong = child(supervisor, Props(new PingPongActor(testActor))) (pingpong, supervisor) } def multipleActorsAllForOne = { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) val pingpong1, pingpong2, pingpong3 = child(supervisor, Props(new PingPongActor(testActor))) (pingpong1, pingpong2, pingpong3, supervisor) } def multipleActorsOneForOne = { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) val pingpong1, pingpong2, pingpong3 = child(supervisor, Props(new PingPongActor(testActor))) (pingpong1, pingpong2, pingpong3, supervisor) } def nestedSupervisorsAllForOne = { - val topSupervisor = actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) + val topSupervisor = system.actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 3, TimeoutMillis))) val pingpong1 = child(topSupervisor, Props(new PingPongActor(testActor))) val middleSupervisor = child(topSupervisor, Props[Supervisor].withFaultHandler(AllForOneStrategy(Nil, 3, TimeoutMillis))) @@ -142,7 +142,7 @@ class SupervisorSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende "A supervisor" must { "not restart child more times than permitted" in { - val master = actorOf(Props(new Master(testActor)).withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(0)))) + val master = system.actorOf(Props(new Master(testActor)).withFaultHandler(OneForOneStrategy(List(classOf[Exception]), Some(0)))) master ! Die expectMsg(3 seconds, "terminated") @@ -278,7 +278,7 @@ class SupervisorSpec extends AkkaSpec with BeforeAndAfterEach with ImplicitSende "must attempt restart when exception during restart" in { val inits = new AtomicInteger(0) - val supervisor = actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(classOf[Exception] :: Nil, 3, 10000))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(OneForOneStrategy(classOf[Exception] :: Nil, 3, 10000))) val dyingProps = Props(new Actor { inits.incrementAndGet diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala index 5794c4d167..9ed84ca2b6 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorTreeSpec.scala @@ -27,7 +27,7 @@ class SupervisorTreeSpec extends AkkaSpec with ImplicitSender with DefaultTimeou } override def preRestart(cause: Throwable, msg: Option[Any]) { testActor ! self.path } }).withFaultHandler(OneForOneStrategy(List(classOf[Exception]), 3, 1000)) - val headActor = actorOf(p) + val headActor = system.actorOf(p) val middleActor = (headActor ? p).as[ActorRef].get val lastActor = (middleActor ? p).as[ActorRef].get diff --git a/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala b/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala index 75d3a88814..154ba58fcd 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/Ticket669Spec.scala @@ -23,7 +23,7 @@ class Ticket669Spec extends AkkaSpec with BeforeAndAfterAll with ImplicitSender "A supervised actor with lifecycle PERMANENT" should { "be able to reply on failure during preRestart" in { filterEvents(EventFilter[Exception]("test", occurrences = 1)) { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 5, 10000))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), 5, 10000))) val supervised = (supervisor ? Props[Supervised]).as[ActorRef].get supervised.!("test")(testActor) @@ -34,7 +34,7 @@ class Ticket669Spec extends AkkaSpec with BeforeAndAfterAll with ImplicitSender "be able to reply on failure during postStop" in { filterEvents(EventFilter[Exception]("test", occurrences = 1)) { - val supervisor = actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), Some(0), None))) + val supervisor = system.actorOf(Props[Supervisor].withFaultHandler(AllForOneStrategy(List(classOf[Exception]), Some(0), None))) val supervised = (supervisor ? Props[Supervised]).as[ActorRef].get supervised.!("test")(testActor) diff --git a/akka-actor-tests/src/test/scala/akka/actor/TypedActorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/TypedActorSpec.scala index 8e06ca4998..3cc54ea6bb 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/TypedActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/TypedActorSpec.scala @@ -285,7 +285,7 @@ class TypedActorSpec extends AkkaSpec with BeforeAndAfterEach with BeforeAndAfte "be able to handle exceptions when calling methods" in { filterEvents(EventFilter[IllegalStateException]("expected")) { - val boss = actorOf(Props(context ⇒ { + val boss = system.actorOf(Props(context ⇒ { case p: Props ⇒ context.sender ! TypedActor(context).typedActorOf(classOf[Foo], classOf[Bar], p) }).withFaultHandler(OneForOneStrategy { case e: IllegalStateException if e.getMessage == "expected" ⇒ FaultHandlingStrategy.Resume diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala index c82e9aec68..bffa5bac82 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala @@ -341,7 +341,7 @@ abstract class ActorModelSpec extends AkkaSpec with DefaultTimeout { val cachedMessage = CountDownNStop(new CountDownLatch(num)) val stopLatch = new CountDownLatch(num) val waitTime = (30 seconds).dilated.toMillis - val boss = actorOf(Props(new Actor { + val boss = system.actorOf(Props(new Actor { def receive = { case "run" ⇒ for (_ ← 1 to num) (context.watch(context.actorOf(props))) ! cachedMessage case Terminated(child) ⇒ stopLatch.countDown() diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/BalancingDispatcherSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/BalancingDispatcherSpec.scala index b6ef8468f7..5ad7794f77 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/BalancingDispatcherSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/BalancingDispatcherSpec.scala @@ -44,8 +44,8 @@ class BalancingDispatcherSpec extends AkkaSpec { "have fast actor stealing work from slow actor" in { val finishedCounter = new CountDownLatch(110) - val slow = actorOf(Props(new DelayableActor(50, finishedCounter)).withDispatcher(delayableActorDispatcher)).asInstanceOf[LocalActorRef] - val fast = actorOf(Props(new DelayableActor(10, finishedCounter)).withDispatcher(delayableActorDispatcher)).asInstanceOf[LocalActorRef] + val slow = system.actorOf(Props(new DelayableActor(50, finishedCounter)).withDispatcher(delayableActorDispatcher)).asInstanceOf[LocalActorRef] + val fast = system.actorOf(Props(new DelayableActor(10, finishedCounter)).withDispatcher(delayableActorDispatcher)).asInstanceOf[LocalActorRef] var sentToFast = 0 diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala index 71e1c57642..c6e04c6cf7 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorSpec.scala @@ -36,14 +36,14 @@ class DispatcherActorSpec extends AkkaSpec with DefaultTimeout { "A Dispatcher and an Actor" must { "support tell" in { - val actor = actorOf(Props[OneWayTestActor].withDispatcher(system.dispatcherFactory.newDispatcher("test").build)) + val actor = system.actorOf(Props[OneWayTestActor].withDispatcher(system.dispatcherFactory.newDispatcher("test").build)) val result = actor ! "OneWay" assert(OneWayTestActor.oneWay.await(1, TimeUnit.SECONDS)) actor.stop() } "support ask/reply" in { - val actor = actorOf(Props[TestActor].withDispatcher(system.dispatcherFactory.newDispatcher("test").build)) + val actor = system.actorOf(Props[TestActor].withDispatcher(system.dispatcherFactory.newDispatcher("test").build)) val result = (actor ? "Hello").as[String] assert("World" === result.get) actor.stop() @@ -58,10 +58,10 @@ class DispatcherActorSpec extends AkkaSpec with DefaultTimeout { val works = new AtomicBoolean(true) val latch = new CountDownLatch(100) val start = new CountDownLatch(1) - val fastOne = actorOf( + val fastOne = system.actorOf( Props(context ⇒ { case "sabotage" ⇒ works.set(false) }).withDispatcher(throughputDispatcher)) - val slowOne = actorOf( + val slowOne = system.actorOf( Props(context ⇒ { case "hogexecutor" ⇒ context.sender ! "OK"; start.await case "ping" ⇒ if (works.get) latch.countDown() @@ -88,12 +88,12 @@ class DispatcherActorSpec extends AkkaSpec with DefaultTimeout { val start = new CountDownLatch(1) val ready = new CountDownLatch(1) - val fastOne = actorOf( + val fastOne = system.actorOf( Props(context ⇒ { case "ping" ⇒ if (works.get) latch.countDown(); context.self.stop() }).withDispatcher(throughputDispatcher)) - val slowOne = actorOf( + val slowOne = system.actorOf( Props(context ⇒ { case "hogexecutor" ⇒ ready.countDown(); start.await case "ping" ⇒ works.set(false); context.self.stop() diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorsSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorsSpec.scala index 650024ebca..71a03c6e01 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorsSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/DispatcherActorsSpec.scala @@ -33,8 +33,8 @@ class DispatcherActorsSpec extends AkkaSpec { "not block fast actors by slow actors" in { val sFinished = new CountDownLatch(50) val fFinished = new CountDownLatch(10) - val s = actorOf(new SlowActor(sFinished)) - val f = actorOf(new FastActor(fFinished)) + val s = system.actorOf(new SlowActor(sFinished)) + val f = system.actorOf(new FastActor(fFinished)) // send a lot of stuff to s for (i ← 1 to 50) { diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/PinnedActorSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/PinnedActorSpec.scala index c692b065e5..c4750a4691 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/PinnedActorSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/PinnedActorSpec.scala @@ -27,14 +27,14 @@ class PinnedActorSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTimeo "support tell" in { var oneWay = new CountDownLatch(1) - val actor = actorOf(Props(self ⇒ { case "OneWay" ⇒ oneWay.countDown() }).withDispatcher(system.dispatcherFactory.newPinnedDispatcher("test"))) + val actor = system.actorOf(Props(self ⇒ { case "OneWay" ⇒ oneWay.countDown() }).withDispatcher(system.dispatcherFactory.newPinnedDispatcher("test"))) val result = actor ! "OneWay" assert(oneWay.await(1, TimeUnit.SECONDS)) actor.stop() } "support ask/reply" in { - val actor = actorOf(Props[TestActor].withDispatcher(system.dispatcherFactory.newPinnedDispatcher("test"))) + val actor = system.actorOf(Props[TestActor].withDispatcher(system.dispatcherFactory.newPinnedDispatcher("test"))) val result = (actor ? "Hello").as[String] assert("World" === result.get) actor.stop() diff --git a/akka-actor-tests/src/test/scala/akka/actor/routing/ListenerSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/routing/ListenerSpec.scala index fdd1844141..8f074a504c 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/routing/ListenerSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/routing/ListenerSpec.scala @@ -16,13 +16,13 @@ class ListenerSpec extends AkkaSpec { val barLatch = TestLatch(2) val barCount = new AtomicInteger(0) - val broadcast = actorOf(new Actor with Listeners { + val broadcast = system.actorOf(new Actor with Listeners { def receive = listenerManagement orElse { case "foo" ⇒ gossip("bar") } }) - def newListener = actorOf(new Actor { + def newListener = system.actorOf(new Actor { def receive = { case "bar" ⇒ barCount.incrementAndGet diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala index 8177ab6c9d..2ef735b05f 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/FutureSpec.scala @@ -116,7 +116,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "from an Actor" that { "returns a result" must { behave like futureWithResult { test ⇒ - val actor = actorOf[TestActor] + val actor = system.actorOf[TestActor] val future = actor ? "Hello" future.await test(future, "World") @@ -126,7 +126,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "throws an exception" must { behave like futureWithException[RuntimeException] { test ⇒ filterException[RuntimeException] { - val actor = actorOf[TestActor] + val actor = system.actorOf[TestActor] val future = actor ? "Failure" future.await test(future, "Expected exception; to test fault-tolerance") @@ -139,8 +139,8 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "using flatMap with an Actor" that { "will return a result" must { behave like futureWithResult { test ⇒ - val actor1 = actorOf[TestActor] - val actor2 = actorOf(new Actor { def receive = { case s: String ⇒ sender ! s.toUpperCase } }) + val actor1 = system.actorOf[TestActor] + val actor2 = system.actorOf(new Actor { def receive = { case s: String ⇒ sender ! s.toUpperCase } }) val future = actor1 ? "Hello" flatMap { case s: String ⇒ actor2 ? s } future.await test(future, "WORLD") @@ -151,8 +151,8 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "will throw an exception" must { behave like futureWithException[ArithmeticException] { test ⇒ filterException[ArithmeticException] { - val actor1 = actorOf[TestActor] - val actor2 = actorOf(new Actor { def receive = { case s: String ⇒ sender ! Status.Failure(new ArithmeticException("/ by zero")) } }) + val actor1 = system.actorOf[TestActor] + val actor2 = system.actorOf(new Actor { def receive = { case s: String ⇒ sender ! Status.Failure(new ArithmeticException("/ by zero")) } }) val future = actor1 ? "Hello" flatMap { case s: String ⇒ actor2 ? s } future.await test(future, "/ by zero") @@ -164,8 +164,8 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "will throw a MatchError when matching wrong type" must { behave like futureWithException[MatchError] { test ⇒ filterException[MatchError] { - val actor1 = actorOf[TestActor] - val actor2 = actorOf(new Actor { def receive = { case s: String ⇒ sender ! s.toUpperCase } }) + val actor1 = system.actorOf[TestActor] + val actor2 = system.actorOf(new Actor { def receive = { case s: String ⇒ sender ! s.toUpperCase } }) val future = actor1 ? "Hello" flatMap { case i: Int ⇒ actor2 ? i } future.await test(future, "World (of class java.lang.String)") @@ -180,7 +180,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "compose with for-comprehensions" in { filterException[ClassCastException] { - val actor = actorOf(new Actor { + val actor = system.actorOf(new Actor { def receive = { case s: String ⇒ sender ! s.length case i: Int ⇒ sender ! (i * 2).toString @@ -212,7 +212,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa filterException[MatchError] { case class Req[T](req: T) case class Res[T](res: T) - val actor = actorOf(new Actor { + val actor = system.actorOf(new Actor { def receive = { case Req(s: String) ⇒ sender ! Res(s.length) case Req(i: Int) ⇒ sender ! Res((i * 2).toString) @@ -257,7 +257,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa val future7 = future3 recover { case e: ArithmeticException ⇒ "You got ERROR" } - val actor = actorOf[TestActor] + val actor = system.actorOf[TestActor] val future8 = actor ? "Failure" val future9 = actor ? "Failure" recover { @@ -300,7 +300,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "fold" in { val actors = (1 to 10).toList map { _ ⇒ - actorOf(new Actor { + system.actorOf(new Actor { def receive = { case (add: Int, wait: Int) ⇒ Thread.sleep(wait); sender.tell(add) } }) } @@ -311,7 +311,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "fold by composing" in { val actors = (1 to 10).toList map { _ ⇒ - actorOf(new Actor { + system.actorOf(new Actor { def receive = { case (add: Int, wait: Int) ⇒ Thread.sleep(wait); sender.tell(add) } }) } @@ -322,7 +322,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "fold with an exception" in { filterException[IllegalArgumentException] { val actors = (1 to 10).toList map { _ ⇒ - actorOf(new Actor { + system.actorOf(new Actor { def receive = { case (add: Int, wait: Int) ⇒ Thread.sleep(wait) @@ -358,7 +358,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "shouldReduceResults" in { val actors = (1 to 10).toList map { _ ⇒ - actorOf(new Actor { + system.actorOf(new Actor { def receive = { case (add: Int, wait: Int) ⇒ Thread.sleep(wait); sender.tell(add) } }) } @@ -370,7 +370,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "shouldReduceResultsWithException" in { filterException[IllegalArgumentException] { val actors = (1 to 10).toList map { _ ⇒ - actorOf(new Actor { + system.actorOf(new Actor { def receive = { case (add: Int, wait: Int) ⇒ Thread.sleep(wait) @@ -393,14 +393,14 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "receiveShouldExecuteOnComplete" in { val latch = new StandardLatch - val actor = actorOf[TestActor] + val actor = system.actorOf[TestActor] actor ? "Hello" onResult { case "World" ⇒ latch.open } assert(latch.tryAwait(5, TimeUnit.SECONDS)) actor.stop() } "shouldTraverseFutures" in { - val oddActor = actorOf(new Actor { + val oddActor = system.actorOf(new Actor { var counter = 1 def receive = { case 'GetNext ⇒ @@ -461,7 +461,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa "futureComposingWithContinuations" in { import Future.flow - val actor = actorOf[TestActor] + val actor = system.actorOf[TestActor] val x = Future("Hello") val y = x flatMap (actor ? _) mapTo manifest[String] @@ -490,7 +490,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa filterException[ClassCastException] { import Future.flow - val actor = actorOf[TestActor] + val actor = system.actorOf[TestActor] val x = Future(3) val y = (actor ? "Hello").mapTo[Int] @@ -505,7 +505,7 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa filterException[ClassCastException] { import Future.flow - val actor = actorOf[TestActor] + val actor = system.actorOf[TestActor] val x = Future("Hello") val y = actor ? "Hello" mapTo manifest[Nothing] diff --git a/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala b/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala index eeb6766b4c..f332f18030 100644 --- a/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/dispatch/PriorityDispatcherSpec.scala @@ -27,7 +27,7 @@ class PriorityDispatcherSpec extends AkkaSpec with DefaultTimeout { def testOrdering(mboxType: MailboxType) { val dispatcher = system.dispatcherFactory.newDispatcher("Test", 1, Duration.Zero, mboxType).build - val actor = actorOf(Props(new Actor { + val actor = system.actorOf(Props(new Actor { var acc: List[Int] = Nil def receive = { diff --git a/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala b/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala index 6e2f672507..5923e84305 100644 --- a/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala @@ -161,7 +161,7 @@ class ActorEventBusSpec extends EventBusSpec("ActorEventBus") { def createEvents(numberOfEvents: Int) = (0 until numberOfEvents) - def createSubscriber(pipeTo: ActorRef) = actorOf(Props(new TestActorWrapperActor(pipeTo))) + def createSubscriber(pipeTo: ActorRef) = system.actorOf(Props(new TestActorWrapperActor(pipeTo))) def classifierFor(event: BusType#Event) = event.toString diff --git a/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala b/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala index fc2a624631..943718848a 100644 --- a/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/routing/ActorPoolSpec.scala @@ -64,9 +64,9 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { val latch = TestLatch(2) val count = new AtomicInteger(0) - val pool = actorOf( + val pool = system.actorOf( Props(new Actor with DefaultActorPool with FixedCapacityStrategy with SmallestMailboxSelector { - def instance(p: Props) = actorOf(p.withCreator(new Actor { + def instance(p: Props) = system.actorOf(p.withCreator(new Actor { def receive = { case _ ⇒ count.incrementAndGet @@ -82,7 +82,7 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { }).withFaultHandler(faultHandler)) val successes = TestLatch(2) - val successCounter = actorOf(new Actor { + val successCounter = system.actorOf(new Actor { def receive = { case "success" ⇒ successes.countDown() } @@ -103,7 +103,7 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { } "pass ticket #705" in { - val pool = actorOf( + val pool = system.actorOf( Props(new Actor with DefaultActorPool with BoundedCapacityStrategy with MailboxPressureCapacitor with SmallestMailboxSelector with BasicFilter { def lowerBound = 2 def upperBound = 20 @@ -114,7 +114,7 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { def selectionCount = 1 def receive = _route def pressureThreshold = 1 - def instance(p: Props) = actorOf(p.withCreator(new Actor { + def instance(p: Props) = system.actorOf(p.withCreator(new Actor { def receive = { case req: String ⇒ { (10 millis).dilated.sleep @@ -140,9 +140,9 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { var latch = TestLatch(3) val count = new AtomicInteger(0) - val pool = actorOf( + val pool = system.actorOf( Props(new Actor with DefaultActorPool with BoundedCapacityStrategy with ActiveActorsPressureCapacitor with SmallestMailboxSelector with BasicNoBackoffFilter { - def instance(p: Props) = actorOf(p.withCreator(new Actor { + def instance(p: Props) = system.actorOf(p.withCreator(new Actor { def receive = { case n: Int ⇒ (n millis).dilated.sleep @@ -204,9 +204,9 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { var latch = TestLatch(3) val count = new AtomicInteger(0) - val pool = actorOf( + val pool = system.actorOf( Props(new Actor with DefaultActorPool with BoundedCapacityStrategy with MailboxPressureCapacitor with SmallestMailboxSelector with BasicNoBackoffFilter { - def instance(p: Props) = actorOf(p.withCreator(new Actor { + def instance(p: Props) = system.actorOf(p.withCreator(new Actor { def receive = { case n: Int ⇒ (n millis).dilated.sleep @@ -257,10 +257,10 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { val latch1 = TestLatch(2) val delegates = new java.util.concurrent.ConcurrentHashMap[String, String] - val pool1 = actorOf( + val pool1 = system.actorOf( Props(new Actor with DefaultActorPool with FixedCapacityStrategy with RoundRobinSelector with BasicNoBackoffFilter { - def instance(p: Props): ActorRef = actorOf(p.withCreator(new Actor { + def instance(p: Props): ActorRef = system.actorOf(p.withCreator(new Actor { def receive = { case _ ⇒ delegates put (self.path.toString, "") @@ -286,9 +286,9 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { val latch2 = TestLatch(2) delegates.clear() - val pool2 = actorOf( + val pool2 = system.actorOf( Props(new Actor with DefaultActorPool with FixedCapacityStrategy with RoundRobinSelector with BasicNoBackoffFilter { - def instance(p: Props) = actorOf(p.withCreator(new Actor { + def instance(p: Props) = system.actorOf(p.withCreator(new Actor { def receive = { case _ ⇒ delegates put (self.path.toString, "") @@ -315,9 +315,9 @@ class ActorPoolSpec extends AkkaSpec with DefaultTimeout { "backoff" in { val latch = TestLatch(10) - val pool = actorOf( + val pool = system.actorOf( Props(new Actor with DefaultActorPool with BoundedCapacityStrategy with MailboxPressureCapacitor with SmallestMailboxSelector with Filter with RunningMeanBackoff with BasicRampup { - def instance(p: Props) = actorOf(p.withCreator(new Actor { + def instance(p: Props) = system.actorOf(p.withCreator(new Actor { def receive = { case n: Int ⇒ (n millis).dilated.sleep diff --git a/akka-actor-tests/src/test/scala/akka/routing/RoutingSpec.scala b/akka-actor-tests/src/test/scala/akka/routing/RoutingSpec.scala index 357f1467a6..fd51501142 100644 --- a/akka-actor-tests/src/test/scala/akka/routing/RoutingSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/routing/RoutingSpec.scala @@ -28,7 +28,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { "direct router" must { "be started when constructed" in { - val actor1 = actorOf[TestActor] + val actor1 = system.actorOf[TestActor] val props = RoutedProps(routerFactory = () ⇒ new DirectRouter, connectionManager = new LocalConnectionManager(List(actor1))) val actor = new RoutedActorRef(system, props, impl.guardian, "foo") @@ -39,7 +39,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(1) val counter = new AtomicInteger(0) - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case _ ⇒ counter.incrementAndGet @@ -60,7 +60,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(1) val counter1 = new AtomicInteger - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter1.addAndGet(msg) @@ -82,7 +82,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { "round robin router" must { "be started when constructed" in { - val actor1 = actorOf[TestActor] + val actor1 = system.actorOf[TestActor] val props = RoutedProps(routerFactory = () ⇒ new RoundRobinRouter, connectionManager = new LocalConnectionManager(List(actor1))) val actor = new RoutedActorRef(system, props, impl.guardian, "foo") @@ -104,7 +104,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { for (i ← 0 until connectionCount) { counters = counters :+ new AtomicInteger() - val connection = actorOf(new Actor { + val connection = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counters.get(i).get.addAndGet(msg) @@ -138,7 +138,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(2) val counter1 = new AtomicInteger - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter1.addAndGet(msg) @@ -146,7 +146,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { }) val counter2 = new AtomicInteger - val connection2 = actorOf(new Actor { + val connection2 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter2.addAndGet(msg) @@ -169,7 +169,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(1) val counter1 = new AtomicInteger - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case _ ⇒ counter1.incrementAndGet() @@ -191,7 +191,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { "be started when constructed" in { - val actor1 = actorOf[TestActor] + val actor1 = system.actorOf[TestActor] val props = RoutedProps(routerFactory = () ⇒ new RandomRouter, connectionManager = new LocalConnectionManager(List(actor1))) val actor = new RoutedActorRef(system, props, impl.guardian, "foo") @@ -202,7 +202,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(2) val counter1 = new AtomicInteger - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter1.addAndGet(msg) @@ -210,7 +210,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { }) val counter2 = new AtomicInteger - val connection2 = actorOf(new Actor { + val connection2 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter2.addAndGet(msg) @@ -233,7 +233,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(1) val counter1 = new AtomicInteger - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case _ ⇒ counter1.incrementAndGet() @@ -406,7 +406,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { "broadcast router" must { "be started when constructed" in { - val actor1 = actorOf[TestActor] + val actor1 = system.actorOf[TestActor] val props = RoutedProps(routerFactory = () ⇒ new BroadcastRouter, connectionManager = new LocalConnectionManager(List(actor1))) val actor = new RoutedActorRef(system, props, system.asInstanceOf[ActorSystemImpl].guardian, "foo") @@ -417,7 +417,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(2) val counter1 = new AtomicInteger - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter1.addAndGet(msg) @@ -425,7 +425,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { }) val counter2 = new AtomicInteger - val connection2 = actorOf(new Actor { + val connection2 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter2.addAndGet(msg) @@ -448,7 +448,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { val doneLatch = new CountDownLatch(2) val counter1 = new AtomicInteger - val connection1 = actorOf(new Actor { + val connection1 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ @@ -458,7 +458,7 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout { }) val counter2 = new AtomicInteger - val connection2 = actorOf(new Actor { + val connection2 = system.actorOf(new Actor { def receive = { case "end" ⇒ doneLatch.countDown() case msg: Int ⇒ counter2.addAndGet(msg) diff --git a/akka-actor-tests/src/test/scala/akka/ticket/Ticket703Spec.scala b/akka-actor-tests/src/test/scala/akka/ticket/Ticket703Spec.scala index 1e1768019e..09b5f5e24c 100644 --- a/akka-actor-tests/src/test/scala/akka/ticket/Ticket703Spec.scala +++ b/akka-actor-tests/src/test/scala/akka/ticket/Ticket703Spec.scala @@ -9,7 +9,7 @@ class Ticket703Spec extends AkkaSpec { "A ? call to an actor pool" should { "reuse the proper timeout" in { - val actorPool = actorOf( + val actorPool = system.actorOf( Props(new Actor with DefaultActorPool with BoundedCapacityStrategy with MailboxPressureCapacitor with SmallestMailboxSelector with BasicNoBackoffFilter { def lowerBound = 2 def upperBound = 20 @@ -18,7 +18,7 @@ class Ticket703Spec extends AkkaSpec { def selectionCount = 1 def receive = _route def pressureThreshold = 1 - def instance(p: Props) = actorOf(p.withCreator(new Actor { + def instance(p: Props) = system.actorOf(p.withCreator(new Actor { def receive = { case req: String ⇒ Thread.sleep(6000L) diff --git a/akka-docs/scala/code/ActorDocSpec.scala b/akka-docs/scala/code/ActorDocSpec.scala index 0e207fb0d0..b796e32971 100644 --- a/akka-docs/scala/code/ActorDocSpec.scala +++ b/akka-docs/scala/code/ActorDocSpec.scala @@ -25,7 +25,7 @@ class ActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) { "creating actor with AkkaSpec.actorOf" in { //#creating-actorOf - val myActor = actorOf[MyActor] + val myActor = system.actorOf[MyActor] //#creating-actorOf // testing the actor @@ -57,7 +57,7 @@ class ActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) { //#creating-constructor // allows passing in arguments to the MyActor constructor - val myActor = actorOf(new MyActor("...")) + val myActor = system.actorOf(new MyActor("...")) //#creating-constructor myActor.stop() diff --git a/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala b/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala index 9d118e3a96..eec1b03192 100644 --- a/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala +++ b/akka-durable-mailboxes/akka-mailboxes-common/src/test/scala/akka/actor/mailbox/DurableMailboxSpec.scala @@ -29,14 +29,14 @@ abstract class DurableMailboxSpec(val backendName: String, val mailboxType: Dura implicit val dispatcher = system.dispatcherFactory.newDispatcher(backendName, throughput = 1, mailboxType = mailboxType).build def createMailboxTestActor(id: String)(implicit dispatcher: MessageDispatcher): ActorRef = - actorOf(Props(new MailboxTestActor).withDispatcher(dispatcher)) + system.actorOf(Props(new MailboxTestActor).withDispatcher(dispatcher)) "A " + backendName + " based mailbox backed actor" must { "handle reply to ! for 1 message" in { val latch = new CountDownLatch(1) val queueActor = createMailboxTestActor(backendName + " should handle reply to !") - val sender = actorOf(Props(new Sender(latch))) + val sender = system.actorOf(Props(new Sender(latch))) queueActor.!("sum")(sender) latch.await(10, TimeUnit.SECONDS) must be(true) @@ -48,7 +48,7 @@ abstract class DurableMailboxSpec(val backendName: String, val mailboxType: Dura "handle reply to ! for multiple messages" ignore { val latch = new CountDownLatch(5) val queueActor = createMailboxTestActor(backendName + " should handle reply to !") - val sender = actorOf(Props(new Sender(latch))) + val sender = system.actorOf(Props(new Sender(latch))) for (i ← 1 to 10) queueActor.!("sum")(sender) diff --git a/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala b/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala index 5ba6e94c8c..1fdbaee7d7 100644 --- a/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala +++ b/akka-testkit/src/test/scala/akka/testkit/AkkaSpec.scala @@ -75,16 +75,8 @@ abstract class AkkaSpec(_system: ActorSystem) protected def atTermination() {} - def actorOf(props: Props): ActorRef = system.actorOf(props) - - def actorOf[T <: Actor](clazz: Class[T]): ActorRef = actorOf(Props(clazz)) - - def actorOf[T <: Actor: Manifest]: ActorRef = actorOf(manifest[T].erasure.asInstanceOf[Class[_ <: Actor]]) - - def actorOf[T <: Actor](factory: ⇒ T): ActorRef = actorOf(Props(factory)) - def spawn(body: ⇒ Unit)(implicit dispatcher: MessageDispatcher) { - actorOf(Props(ctx ⇒ { case "go" ⇒ try body finally ctx.self.stop() }).withDispatcher(dispatcher)) ! "go" + system.actorOf(Props(ctx ⇒ { case "go" ⇒ try body finally ctx.self.stop() }).withDispatcher(dispatcher)) ! "go" } } diff --git a/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala b/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala index 520bdbb566..462ee6ffc6 100644 --- a/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala +++ b/akka-testkit/src/test/scala/akka/testkit/TestActorRefSpec.scala @@ -156,7 +156,7 @@ class TestActorRefSpec extends AkkaSpec with BeforeAndAfterEach with DefaultTime "stop when sent a poison pill" in { EventFilter[ActorKilledException]() intercept { val a = TestActorRef(Props[WorkerActor]) - val forwarder = actorOf(Props(new Actor { + val forwarder = system.actorOf(Props(new Actor { context.watch(a) def receive = { case x ⇒ testActor forward x } }))