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