Merge branch 'tmp'
This commit is contained in:
commit
9463c9ff6c
2 changed files with 78 additions and 75 deletions
|
|
@ -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 {
|
||||
|
|
@ -16,8 +18,6 @@ object FaultHandlingDocSpec {
|
|||
import akka.actor.Actor
|
||||
|
||||
//#child
|
||||
//#supervisor
|
||||
//#supervisor
|
||||
class Supervisor extends Actor {
|
||||
//#strategy
|
||||
import akka.actor.OneForOneStrategy
|
||||
|
|
@ -79,7 +79,6 @@ object FaultHandlingDocSpec {
|
|||
|
||||
def receive = Actor.emptyBehavior
|
||||
}
|
||||
//#supervisor
|
||||
|
||||
//#child
|
||||
class Child extends Actor {
|
||||
|
|
@ -91,18 +90,24 @@ object FaultHandlingDocSpec {
|
|||
}
|
||||
}
|
||||
//#child
|
||||
|
||||
val testConf: Config = ConfigFactory.parseString("""
|
||||
akka {
|
||||
loggers = ["akka.testkit.TestEventListener"]
|
||||
}
|
||||
""")
|
||||
}
|
||||
|
||||
import FaultHandlingDocSpec._
|
||||
//#testkit
|
||||
class FaultHandlingDocSpec extends AkkaSpec with ImplicitSender {
|
||||
//#testkit
|
||||
class FaultHandlingDocSpec extends TestKit(ActorSystem("FaultHandlingDocSpec", testConf))
|
||||
with FlatSpecLike with BeforeAndAfterAll with ImplicitSender {
|
||||
|
||||
import FaultHandlingDocSpec._
|
||||
//#testkit
|
||||
override def afterAll() {
|
||||
system.terminate()
|
||||
}
|
||||
|
||||
"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 +145,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 +172,5 @@ class FaultHandlingDocSpec extends AkkaSpec with ImplicitSender {
|
|||
//#testkit
|
||||
// code here
|
||||
}
|
||||
}
|
||||
}
|
||||
//#testkit
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ This supervisor will be used to create a child, with which we can experiment:
|
|||
:include: child
|
||||
|
||||
The test is easier by using the utilities described in :ref:`akka-testkit`,
|
||||
where ``AkkaSpec`` is a convenient mixture of ``TestKit with WordSpec with
|
||||
MustMatchers``
|
||||
where ``AkkaSpec`` is a convenient mixture of
|
||||
``TestKit with WordSpec with MustMatchers``
|
||||
|
||||
.. includecode:: code/docs/actor/FaultHandlingDocSpec.scala
|
||||
:include: testkit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue