+tes #12681 add EchoActor

This commit is contained in:
Michal Knapik 2014-06-04 20:51:12 +02:00 committed by Konrad 'ktoso' Malawski
parent 0e2f356d23
commit 7ca3a9699e
5 changed files with 53 additions and 37 deletions

View file

@ -7,19 +7,10 @@ package docs.testkit
import akka.actor.ActorSystem
import akka.actor.Actor
import akka.actor.Props
import akka.testkit.TestKit
import akka.testkit.{ TestActors, TestKit, ImplicitSender }
import org.scalatest.WordSpecLike
import org.scalatest.Matchers
import org.scalatest.BeforeAndAfterAll
import akka.testkit.ImplicitSender
object MySpec {
class EchoActor extends Actor {
def receive = {
case x => sender() ! x
}
}
}
//#implicit-sender
class MySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
@ -28,8 +19,6 @@ class MySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
def this() = this(ActorSystem("MySpec"))
import MySpec._
override def afterAll {
TestKit.shutdownActorSystem(system)
}
@ -37,7 +26,7 @@ class MySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
"An Echo actor" must {
"send back messages unchanged" in {
val echo = system.actorOf(Props[EchoActor])
val echo = system.actorOf(TestActors.echoActorProps)
echo ! "hello world"
expectMsg("hello world")
}