2011-12-07 16:29:12 +01:00
|
|
|
/**
|
2013-01-09 01:47:48 +01:00
|
|
|
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
|
2011-12-07 16:29:12 +01:00
|
|
|
*/
|
|
|
|
|
package akka.remote
|
|
|
|
|
|
|
|
|
|
import akka.testkit._
|
|
|
|
|
import akka.actor._
|
2011-12-12 23:31:15 +01:00
|
|
|
import akka.routing._
|
2011-12-07 16:29:12 +01:00
|
|
|
import com.typesafe.config._
|
|
|
|
|
|
|
|
|
|
object RemoteDeployerSpec {
|
|
|
|
|
val deployerConf = ConfigFactory.parseString("""
|
|
|
|
|
akka.actor.provider = "akka.remote.RemoteActorRefProvider"
|
|
|
|
|
akka.actor.deployment {
|
2013-05-29 16:13:10 +02:00
|
|
|
/service2 {
|
2011-12-07 16:29:12 +01:00
|
|
|
router = round-robin
|
|
|
|
|
nr-of-instances = 3
|
2011-12-11 20:00:26 +01:00
|
|
|
remote = "akka://sys@wallace:2552"
|
2013-04-05 16:12:45 +02:00
|
|
|
dispatcher = mydispatcher
|
2011-12-07 16:29:12 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-01-17 16:19:31 +01:00
|
|
|
akka.remote.netty.tcp.port = 0
|
2011-12-07 16:29:12 +01:00
|
|
|
""", ConfigParseOptions.defaults)
|
|
|
|
|
|
|
|
|
|
class RecipeActor extends Actor {
|
|
|
|
|
def receive = { case _ ⇒ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
|
|
|
|
|
class RemoteDeployerSpec extends AkkaSpec(RemoteDeployerSpec.deployerConf) {
|
|
|
|
|
|
|
|
|
|
"A RemoteDeployer" must {
|
|
|
|
|
|
|
|
|
|
"be able to parse 'akka.actor.deployment._' with specified remote nodes" in {
|
2013-05-29 16:13:10 +02:00
|
|
|
val service = "/service2"
|
2012-04-27 12:48:22 +02:00
|
|
|
val deployment = system.asInstanceOf[ActorSystemImpl].provider.deployer.lookup(service.split("/").drop(1))
|
2011-12-07 16:29:12 +01:00
|
|
|
|
|
|
|
|
deployment must be(Some(
|
|
|
|
|
Deploy(
|
|
|
|
|
service,
|
2011-12-12 23:31:15 +01:00
|
|
|
deployment.get.config,
|
|
|
|
|
RoundRobinRouter(3),
|
2013-04-05 16:12:45 +02:00
|
|
|
RemoteScope(Address("akka", "sys", "wallace", 2552)),
|
|
|
|
|
"mydispatcher")))
|
2011-12-07 16:29:12 +01:00
|
|
|
}
|
|
|
|
|
|
2013-05-29 16:13:10 +02:00
|
|
|
"reject remote deployment when the source requires LocalScope" in {
|
|
|
|
|
intercept[IllegalArgumentException] {
|
|
|
|
|
system.actorOf(Props.empty.withDeploy(Deploy.local), "service2")
|
|
|
|
|
}.getMessage must be === "configuration requested remote deployment for local-only Props at [akka://RemoteDeployerSpec/user/service2]"
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-07 16:29:12 +01:00
|
|
|
}
|
|
|
|
|
|
2013-01-09 01:47:48 +01:00
|
|
|
}
|