Added a future-composition test to ThaipedActor
This commit is contained in:
parent
cd7538eace
commit
1ac7b47fd7
1 changed files with 14 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ object ThaipedActorSpec {
|
|||
def futurePigdog(): Future[String]
|
||||
def futurePigdog(delay: Long): Future[String]
|
||||
def futurePigdog(delay: Long, numbered: Int): Future[String]
|
||||
def futureComposePigdogFrom(foo: Foo): Future[String]
|
||||
|
||||
def optionPigdog(): Option[String]
|
||||
def optionPigdog(delay: Long): Option[String]
|
||||
|
|
@ -40,11 +41,14 @@ object ThaipedActorSpec {
|
|||
futurePigdog
|
||||
}
|
||||
|
||||
def futurePigdog(delay: Long, numbered: Int): Future[String] ={
|
||||
def futurePigdog(delay: Long, numbered: Int): Future[String] = {
|
||||
Thread.sleep(delay)
|
||||
new AlreadyCompletedFuture(Right(pigdog + numbered))
|
||||
}
|
||||
|
||||
def futureComposePigdogFrom(foo: Foo): Future[String] =
|
||||
foo.futurePigdog(500).map(_.toUpperCase)
|
||||
|
||||
def optionPigdog(): Option[String] = Some(pigdog)
|
||||
|
||||
def optionPigdog(delay: Long): Option[String] = {
|
||||
|
|
@ -162,6 +166,15 @@ class ThaipedActorSpec extends
|
|||
mustStop(t)
|
||||
}
|
||||
|
||||
"be able to compose futures without blocking" in {
|
||||
val t,t2 = newFooBar(Duration(2,"s"))
|
||||
val f = t.futureComposePigdogFrom(t2)
|
||||
f.isCompleted must be (false)
|
||||
f.get must equal ("PIGDOG")
|
||||
mustStop(t)
|
||||
mustStop(t2)
|
||||
}
|
||||
|
||||
"be able to use work-stealing dispatcher" in {
|
||||
val config = Configuration(
|
||||
Duration(6600,"ms"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue