Simplified the test cases for Future.or

This commit is contained in:
Viktor Klang 2012-01-17 15:54:56 +01:00
parent a019c9e8a6
commit 3f0b1772c8

View file

@ -49,17 +49,16 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa
"never completed" must {
behave like emptyFuture(_(Promise()))
"return supplied value on timeout" in {
val f = new RuntimeException("br0ken")
val failure = Promise.failed[String](new RuntimeException("br0ken"))
val otherFailure = Promise.failed[String](new RuntimeException("last"))
val empty = Promise[String]()
val timedOut = Promise.successful[String]("Timedout")
val promise1 = Promise.failed[String](f) or timedOut
val promise2 = timedOut or Promise[String]()
val promise3 = Promise.failed[String](f) or Promise.failed[String](f) or timedOut
val promise4 = Promise.failed[String](f) or Promise.failed[String](new RuntimeException("last"))
Await.result(promise1, timeout.duration) must be("Timedout")
Await.result(promise2, timeout.duration) must be("Timedout")
Await.result(promise3, timeout.duration) must be("Timedout")
Await.result(failure or timedOut, timeout.duration) must be("Timedout")
Await.result(timedOut or empty, timeout.duration) must be("Timedout")
Await.result(failure or failure or timedOut, timeout.duration) must be("Timedout")
intercept[RuntimeException] {
Await.result(promise4, timeout.duration)
Await.result(failure or otherFailure, timeout.duration)
}.getMessage must be("last")
}
}