Tests are green with new Futures, consider this a half-way-there marker

This commit is contained in:
Viktor Klang 2011-12-11 00:40:52 +01:00
parent b4f486667f
commit 3b1330c6d7
33 changed files with 287 additions and 601 deletions

View file

@ -17,13 +17,9 @@ abstract class MailboxSpec extends AkkaSpec with BeforeAndAfterAll with BeforeAn
val q = factory(config)
ensureInitialMailboxState(config, q)
implicit val within = 1 second
val f = spawn { q.dequeue }
val f = spawn {
q.dequeue
}
f.await.resultOrException must be === Some(null)
Block.on(f, 1 second).resultOrException must be === Some(null)
}
"create a bounded mailbox with 10 capacity and with push timeout" in {
@ -61,8 +57,8 @@ abstract class MailboxSpec extends AkkaSpec with BeforeAndAfterAll with BeforeAn
}
//CANDIDATE FOR TESTKIT
def spawn[T <: AnyRef](fun: T)(implicit within: Duration): Future[T] = {
val result = new DefaultPromise[T](within.length, within.unit)
def spawn[T <: AnyRef](fun: T): Future[T] = {
val result = Promise[T]()
val t = new Thread(new Runnable {
def run = try {
result.completeWithResult(fun)
@ -119,8 +115,8 @@ abstract class MailboxSpec extends AkkaSpec with BeforeAndAfterAll with BeforeAn
val consumers = for (i (1 to 4).toList) yield createConsumer
val ps = producers.map(_.await.resultOrException.get)
val cs = consumers.map(_.await.resultOrException.get)
val ps = producers.map(Block.on(_, within).resultOrException.get)
val cs = consumers.map(Block.on(_, within).resultOrException.get)
ps.map(_.size).sum must be === totalMessages //Must have produced 1000 messages
cs.map(_.size).sum must be === totalMessages //Must have consumed all produced messages