2011-03-05 14:36:08 +01:00
|
|
|
package akka.testkit
|
|
|
|
|
|
|
|
|
|
import akka.actor.dispatch.ActorModelSpec
|
2011-03-17 22:18:39 +01:00
|
|
|
import java.util.concurrent.CountDownLatch
|
2011-03-05 14:36:08 +01:00
|
|
|
|
2011-03-06 21:53:09 +01:00
|
|
|
class CallingThreadDispatcherModelSpec extends ActorModelSpec {
|
2011-03-05 14:36:08 +01:00
|
|
|
import ActorModelSpec._
|
|
|
|
|
def newInterceptedDispatcher = new CallingThreadDispatcher with MessageDispatcherInterceptor
|
2011-03-17 22:18:39 +01:00
|
|
|
|
2011-03-05 14:36:08 +01:00
|
|
|
override def dispatcherShouldProcessMessagesInParallel {}
|
2011-03-17 22:18:39 +01:00
|
|
|
|
|
|
|
|
override def dispatcherShouldHandleWavesOfActors {
|
|
|
|
|
implicit val dispatcher = newInterceptedDispatcher
|
|
|
|
|
|
|
|
|
|
def flood(num: Int) {
|
|
|
|
|
val cachedMessage = CountDownNStop(new CountDownLatch(num))
|
|
|
|
|
val keeper = newTestActor.start
|
|
|
|
|
(1 to num) foreach {
|
|
|
|
|
_ => newTestActor.start ! cachedMessage
|
|
|
|
|
}
|
|
|
|
|
keeper.stop
|
|
|
|
|
assertCountDown(cachedMessage.latch,10000, "Should process " + num + " countdowns")
|
|
|
|
|
}
|
|
|
|
|
for(run <- 1 to 3) {
|
|
|
|
|
flood(10000)
|
|
|
|
|
await(dispatcher.stops.get == run)(withinMs = 10000)
|
|
|
|
|
assertDispatcher(dispatcher)(starts = run, stops = run)
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-05 14:36:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// vim: set ts=4 sw=4 et:
|