improve docs for expecting exceptions

This commit is contained in:
Roland 2011-12-23 21:31:12 +01:00
parent f510293d59
commit d257ad191b
2 changed files with 50 additions and 25 deletions

View file

@ -231,4 +231,23 @@ class TestkitDocSpec extends AkkaSpec with DefaultTimeout with ImplicitSender {
//#calling-thread-dispatcher
}
"demonstrate EventFilter" in {
//#event-filter
import akka.testkit.EventFilter
import com.typesafe.config.ConfigFactory
implicit val system = ActorSystem("testsystem", ConfigFactory.parseString("""
akka.event-handlers = ["akka.testkit.TestEventListener"]
"""))
try {
val actor = system.actorOf(Props.empty)
EventFilter[ActorKilledException](occurrences = 1) intercept {
actor ! Kill
}
} finally {
system.shutdown()
}
//#event-filter
}
}