Make RoutingSpec more robust, see #2484
This commit is contained in:
parent
19d01442ec
commit
bb5ab968db
1 changed files with 10 additions and 19 deletions
|
|
@ -102,8 +102,6 @@ class RoutingSpec extends AkkaSpec(RoutingSpec.config) with DefaultTimeout with
|
|||
}
|
||||
|
||||
"be able to send their routees" in {
|
||||
val doneLatch = new TestLatch(1)
|
||||
|
||||
class TheActor extends Actor {
|
||||
val routee1 = context.actorOf(Props[TestActor], "routee1")
|
||||
val routee2 = context.actorOf(Props[TestActor], "routee2")
|
||||
|
|
@ -114,19 +112,18 @@ class RoutingSpec extends AkkaSpec(RoutingSpec.config) with DefaultTimeout with
|
|||
within = 5 seconds)))
|
||||
|
||||
def receive = {
|
||||
case RouterRoutees(iterable) ⇒
|
||||
iterable.exists(_.path.name == "routee1") must be(true)
|
||||
iterable.exists(_.path.name == "routee2") must be(true)
|
||||
iterable.exists(_.path.name == "routee3") must be(true)
|
||||
doneLatch.countDown()
|
||||
case "doIt" ⇒
|
||||
router ! CurrentRoutees
|
||||
case "doIt" ⇒ router ! CurrentRoutees
|
||||
case routees: RouterRoutees ⇒ testActor forward routees
|
||||
}
|
||||
}
|
||||
|
||||
val theActor = system.actorOf(Props(new TheActor), "theActor")
|
||||
theActor ! "doIt"
|
||||
Await.ready(doneLatch, remaining)
|
||||
val routees = expectMsgPF() {
|
||||
case RouterRoutees(routees) ⇒ routees.toSet
|
||||
}
|
||||
|
||||
routees.map(_.path.name) must be(Set("routee1", "routee2", "routee3"))
|
||||
}
|
||||
|
||||
"use configured nr-of-instances when FromConfig" in {
|
||||
|
|
@ -226,14 +223,9 @@ class RoutingSpec extends AkkaSpec(RoutingSpec.config) with DefaultTimeout with
|
|||
}
|
||||
|
||||
"send message to connection" in {
|
||||
val doneLatch = new TestLatch(1)
|
||||
|
||||
val counter = new AtomicInteger(0)
|
||||
|
||||
class Actor1 extends Actor {
|
||||
def receive = {
|
||||
case "end" ⇒ doneLatch.countDown()
|
||||
case _ ⇒ counter.incrementAndGet
|
||||
case msg ⇒ testActor forward msg
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,9 +233,8 @@ class RoutingSpec extends AkkaSpec(RoutingSpec.config) with DefaultTimeout with
|
|||
routedActor ! "hello"
|
||||
routedActor ! "end"
|
||||
|
||||
Await.ready(doneLatch, remaining)
|
||||
|
||||
counter.get must be(1)
|
||||
expectMsg("hello")
|
||||
expectMsg("end")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue