|
Akka/Scala example source code file (ActorTimeoutSpec.scala)
The ActorTimeoutSpec.scala Akka example source code
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor
import scala.concurrent.duration._
import akka.testkit._
import akka.testkit.TestEvent._
import scala.concurrent.Await
import akka.util.Timeout
import akka.pattern.{ ask, AskTimeoutException }
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class ActorTimeoutSpec extends AkkaSpec {
val testTimeout = 200.millis.dilated
val leeway = 500.millis.dilated
system.eventStream.publish(Mute(EventFilter.warning(pattern = ".*unhandled message from.*hallo")))
"An Actor-based Future" must {
"use implicitly supplied timeout" in {
implicit val timeout = Timeout(testTimeout)
val echo = system.actorOf(Props.empty)
val f = (echo ? "hallo")
intercept[AskTimeoutException] { Await.result(f, testTimeout + leeway) }
}
"use explicitly supplied timeout" in {
val echo = system.actorOf(Props.empty)
val f = echo.?("hallo")(testTimeout)
intercept[AskTimeoutException] { Await.result(f, testTimeout + leeway) }
}
}
}
Other Akka source code examplesHere is a short list of links related to this Akka ActorTimeoutSpec.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.