Verify config override of router nr-of-instances. See #1607

* It wasn't a bug. I think the confusion came from config without 'router' defined.
* Added test
* Added some clarification to docs
This commit is contained in:
Patrik Nordwall 2012-01-10 17:50:17 +01:00
parent 0d4763c3b0
commit 762a6017e9
4 changed files with 34 additions and 5 deletions

View file

@ -15,6 +15,15 @@ import com.typesafe.config.ConfigFactory
object RoutingSpec {
val config = """
akka.actor.deployment {
/router1 {
router = round-robin
nr-of-instances = 3
}
}
"""
class TestActor extends Actor {
def receive = {
case _
@ -31,7 +40,7 @@ object RoutingSpec {
}
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
class RoutingSpec extends AkkaSpec(RoutingSpec.config) with DefaultTimeout with ImplicitSender {
import akka.routing.RoutingSpec._
@ -87,6 +96,18 @@ class RoutingSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
Await.ready(doneLatch, 1 seconds)
}
"use configured nr-of-instances when FromConfig" in {
val router = system.actorOf(Props[TestActor].withRouter(FromConfig), "router1")
Await.result(router ? CurrentRoutees, 5 seconds).asInstanceOf[RouterRoutees].routees.size must be(3)
system.stop(router)
}
"use configured nr-of-instances when router is specified" in {
val router = system.actorOf(Props[TestActor].withRouter(RoundRobinRouter(nrOfInstances = 2)), "router1")
Await.result(router ? CurrentRoutees, 5 seconds).asInstanceOf[RouterRoutees].routees.size must be(3)
system.stop(router)
}
}
"no router" must {