=doc #16459 change confusing FaultHandlingDocSpec in Fault Tolerance Document.

This commit is contained in:
sangche 2014-12-22 19:55:05 -08:00
parent c56d670c03
commit c0867e1308

View file

@ -6,8 +6,10 @@ package docs.actor
import language.postfixOps
//#testkit
import akka.testkit.{ AkkaSpec, ImplicitSender, EventFilter }
import akka.actor.{ ActorRef, Props, Terminated }
import akka.testkit.{ TestKit, ImplicitSender, EventFilter }
import akka.actor.{ ActorRef, Props, ActorSystem, Terminated }
import org.scalatest._
import com.typesafe.config.{ Config, ConfigFactory }
//#testkit
object FaultHandlingDocSpec {
@ -91,18 +93,25 @@ object FaultHandlingDocSpec {
}
}
//#child
val testConf: Config = ConfigFactory.parseString("""
akka {
loggers = ["akka.testkit.TestEventListener"]
}
""")
}
import FaultHandlingDocSpec._
//#testkit
class FaultHandlingDocSpec extends AkkaSpec with ImplicitSender {
class FaultHandlingDocSpec extends TestKit(ActorSystem("FaultHandlingDocSpec", testConf))
with FlatSpecLike with BeforeAndAfterAll with ImplicitSender {
override def afterAll() {
system.terminate()
}
//#testkit
import FaultHandlingDocSpec._
//#testkit
"A supervisor" must {
"apply the chosen strategy for its child" in {
"A supervisor" must "apply the chosen strategy for its child" in {
//#testkit
//#create
@ -140,7 +149,6 @@ class FaultHandlingDocSpec extends AkkaSpec with ImplicitSender {
//#escalate-kill
supervisor ! Props[Child] // create new child
val child2 = expectMsgType[ActorRef]
watch(child2)
child2 ! "get" // verify it is alive
expectMsg(0)
@ -168,6 +176,5 @@ class FaultHandlingDocSpec extends AkkaSpec with ImplicitSender {
//#testkit
// code here
}
}
}
//#testkit