Adding tests for optimize local scoped and non-optimized local scoped
This commit is contained in:
parent
83c8bb7767
commit
0a6567ed80
4 changed files with 71 additions and 6 deletions
|
|
@ -128,7 +128,8 @@ object Actor extends Logging {
|
|||
* val actor = actorOf[MyActor].start
|
||||
* </pre>
|
||||
*/
|
||||
@deprecated def actorOf[T <: Actor : Manifest]: ActorRef = ActorRegistry.actorOf[T]
|
||||
@deprecated("Use ActorRegistry.actorOf instead")
|
||||
def actorOf[T <: Actor : Manifest]: ActorRef = ActorRegistry.actorOf[T]
|
||||
|
||||
/**
|
||||
* Creates an ActorRef out of the Actor of the specified Class.
|
||||
|
|
@ -144,7 +145,8 @@ object Actor extends Logging {
|
|||
* val actor = actorOf(classOf[MyActor]).start
|
||||
* </pre>
|
||||
*/
|
||||
@deprecated def actorOf(clazz: Class[_ <: Actor]): ActorRef = ActorRegistry.actorOf(clazz)
|
||||
@deprecated("Use ActorRegistry.actorOf instead")
|
||||
def actorOf(clazz: Class[_ <: Actor]): ActorRef = ActorRegistry.actorOf(clazz)
|
||||
|
||||
/**
|
||||
* Creates an ActorRef out of the Actor. Allows you to pass in a factory function
|
||||
|
|
@ -164,7 +166,8 @@ object Actor extends Logging {
|
|||
* val actor = actorOf(new MyActor).start
|
||||
* </pre>
|
||||
*/
|
||||
@deprecated def actorOf(factory: => Actor): ActorRef = ActorRegistry.actorOf(factory)
|
||||
@deprecated("Use ActorRegistry.actorOf instead")
|
||||
def actorOf(factory: => Actor): ActorRef = ActorRegistry.actorOf(factory)
|
||||
|
||||
/**
|
||||
* Use to spawn out a block of code in an event-driven actor. Will shut actor down when
|
||||
|
|
@ -181,7 +184,8 @@ object Actor extends Logging {
|
|||
* }
|
||||
* </pre>
|
||||
*/
|
||||
@deprecated def spawn(body: => Unit)(implicit dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher): Unit =
|
||||
@deprecated("Use ActorRegistry.spawn instead")
|
||||
def spawn(body: => Unit)(implicit dispatcher: MessageDispatcher = Dispatchers.defaultGlobalDispatcher): Unit =
|
||||
ActorRegistry.spawn(body)
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -31,14 +31,18 @@ class AkkaRemoteTest extends
|
|||
val host = "localhost"
|
||||
val port = 25520
|
||||
|
||||
def OptimizeLocal = false
|
||||
|
||||
var optimizeLocal_? = remote.asInstanceOf[NettyRemoteSupport].optimizeLocalScoped_?
|
||||
|
||||
override def beforeAll {
|
||||
remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(false) //Can't run the test if we're eliminating all remote calls
|
||||
if (!OptimizeLocal)
|
||||
remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(false) //Can't run the test if we're eliminating all remote calls
|
||||
}
|
||||
|
||||
override def afterAll {
|
||||
remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(optimizeLocal_?) //Reset optimizelocal after all tests
|
||||
if (!OptimizeLocal)
|
||||
remote.asInstanceOf[NettyRemoteSupport].optimizeLocal.set(optimizeLocal_?) //Reset optimizelocal after all tests
|
||||
}
|
||||
|
||||
override def beforeEach {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package akka.actor.remote
|
||||
|
||||
import akka.actor. {ActorRegistry, Actor}
|
||||
|
||||
object OptimizedLocalScopedSpec {
|
||||
class TestActor extends Actor {
|
||||
def receive = { case _ => }
|
||||
}
|
||||
}
|
||||
|
||||
class OptimizedLocalScopedSpec extends AkkaRemoteTest {
|
||||
import OptimizedLocalScopedSpec._
|
||||
override def OptimizeLocal = true
|
||||
|
||||
"An enabled optimized local scoped remote" should {
|
||||
"Fetch local actor ref when scope is local" in {
|
||||
val fooActor = ActorRegistry.actorOf[TestActor].start
|
||||
remote.register("foo", fooActor)
|
||||
|
||||
remote.actorFor("foo", host, port) must be (fooActor)
|
||||
}
|
||||
|
||||
"Create local actor when client-managed is hosted locally" in {
|
||||
val localClientManaged = ActorRegistry.remote.actorOf[TestActor](host, port)
|
||||
localClientManaged.homeAddress must be (None)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package akka.actor.remote
|
||||
import akka.actor. {ActorRegistry, Actor}
|
||||
|
||||
object UnOptimizedLocalScopedSpec {
|
||||
class TestActor extends Actor {
|
||||
def receive = { case _ => }
|
||||
}
|
||||
}
|
||||
|
||||
class UnOptimizedLocalScopedSpec extends AkkaRemoteTest {
|
||||
import UnOptimizedLocalScopedSpec._
|
||||
override def OptimizeLocal = false
|
||||
|
||||
"An enabled optimized local scoped remote" should {
|
||||
"Fetch local actor ref when scope is local" in {
|
||||
val fooActor = ActorRegistry.actorOf[TestActor].start
|
||||
remote.register("foo", fooActor)
|
||||
|
||||
remote.actorFor("foo", host, port) must not be (fooActor)
|
||||
}
|
||||
|
||||
"Create local actor when client-managed is hosted locally" in {
|
||||
val localClientManaged = ActorRegistry.remote.actorOf[TestActor](host, port)
|
||||
localClientManaged.homeAddress must not be (None)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue