Closing ticket #372, added tests

This commit is contained in:
Viktor Klang 2010-08-09 23:08:22 +02:00
parent 19f00f1161
commit 22cf40a971

View file

@ -44,6 +44,39 @@ class SchedulerSpec extends JUnitSuite {
// should still be 1 left
assert(countDownLatch.getCount == 1)
}
/**
* ticket #372
*/
@Test def schedulerShouldntCreateActors = withCleanEndState {
object Ping
val ticks = new CountDownLatch(1000)
val actor = actorOf(new Actor {
def receive = { case Ping => ticks.countDown }
}).start
val numActors = ActorRegistry.actors.length
(1 to 1000).foreach( _ => Scheduler.scheduleOnce(actor,Ping,1,TimeUnit.MILLISECONDS) )
assert(ticks.await(10,TimeUnit.SECONDS))
assert(ActorRegistry.actors.length === numActors)
}
/**
* ticket #372
*/
@Test def schedulerShouldBeCancellable = withCleanEndState {
object Ping
val ticks = new CountDownLatch(1)
val actor = actorOf(new Actor {
def receive = { case Ping => ticks.countDown }
}).start
(1 to 10).foreach { i =>
val future = Scheduler.scheduleOnce(actor,Ping,1,TimeUnit.SECONDS)
future.cancel(true)
}
assert(ticks.await(3,TimeUnit.SECONDS) == false) //No counting down should've been made
}
/**
* ticket #307