2011-05-19 21:34:21 +02:00
|
|
|
/**
|
2011-07-14 16:03:08 +02:00
|
|
|
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
|
2011-05-19 21:34:21 +02:00
|
|
|
*/
|
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-07-26 18:33:59 +12:00
|
|
|
import org.junit.{ After, Test }
|
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
|
|
|
def newInterceptedDispatcher = new CallingThreadDispatcher with MessageDispatcherInterceptor
|
2011-10-11 16:05:48 +02:00
|
|
|
def dispatcherType = "Calling Thread Dispatcher"
|
2011-03-17 22:18:39 +01:00
|
|
|
|
2011-03-27 10:25:01 +02:00
|
|
|
// A CallingThreadDispatcher can by design not process messages in parallel,
|
|
|
|
|
// so disable this test
|
2011-10-11 16:05:48 +02:00
|
|
|
//override def dispatcherShouldProcessMessagesInParallel {}
|
2011-03-17 22:18:39 +01:00
|
|
|
|
2011-03-27 10:25:01 +02:00
|
|
|
// This test needs to be adapted: CTD runs the flood completely sequentially
|
|
|
|
|
// with start, invocation, stop, schedule shutdown, abort shutdown, repeat;
|
|
|
|
|
// add "keeper" actor to lock down the dispatcher instance, since the
|
|
|
|
|
// frequent attempted shutdown seems rather costly (random timing failures
|
|
|
|
|
// without this fix)
|
2011-10-11 16:05:48 +02:00
|
|
|
// override def dispatcherShouldHandleWavesOfActors {
|
|
|
|
|
// implicit val dispatcher = newInterceptedDispatcher
|
|
|
|
|
//
|
|
|
|
|
// def flood(num: Int) {
|
|
|
|
|
// val cachedMessage = CountDownNStop(new CountDownLatch(num))
|
|
|
|
|
// val keeper = newTestActor
|
|
|
|
|
// (1 to num) foreach { _ ⇒
|
|
|
|
|
// newTestActor ! cachedMessage
|
|
|
|
|
// }
|
|
|
|
|
// keeper.stop()
|
|
|
|
|
// assertCountDown(cachedMessage.latch, 10000, "Should process " + num + " countdowns")
|
|
|
|
|
// }
|
|
|
|
|
// for (run ← 1 to 3) {
|
|
|
|
|
// flood(10000)
|
|
|
|
|
// assertDispatcher(dispatcher)(starts = run, stops = run)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
//override def dispatcherShouldCompleteAllUncompletedSenderFuturesOnDeregister {
|
|
|
|
|
//Can't handle this...
|
|
|
|
|
//}
|
2011-05-26 20:38:42 +02:00
|
|
|
|
2011-07-15 11:17:02 +02:00
|
|
|
@After
|
|
|
|
|
def after {
|
|
|
|
|
//remove the interrupted status since we are messing with interrupted exceptions.
|
|
|
|
|
Thread.interrupted()
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-05 14:36:08 +01:00
|
|
|
}
|
|
|
|
|
|
2011-03-27 10:25:01 +02:00
|
|
|
// vim: set ts=2 sw=2 et:
|