Mercurial > hg > Members > anatofuz > akka-increment-sample
view src/test/scala/IncrementSampleSpec.scala @ 7:3b99f171603d default tip
add system.terminate()
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 30 Jan 2018 13:35:32 +0900 |
parents | 230a3627b7d7 |
children |
line wrap: on
line source
package IncrementSampleSpec import IncrementSample.Incrementer import IncrementSample.Incrementer._ import IncrementSample.Incrementer.SetActor import IncrementSample.Printer.Println import akka.actor.ActorSystem import akka.pattern.ask import akka.testkit.{TestActorRef, TestFSMRef, TestKit, TestProbe} import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike} import scala.concurrent.duration._ class IncrementSampleSpec(_system: ActorSystem) extends TestKit(_system) with WordSpecLike with Matchers with BeforeAndAfterAll { def this() = this(ActorSystem("IncrementSampleSpec")) override def afterAll(): Unit = { shutdown(system) } " Increment 1 to 10" in { val testProbe = TestProbe() val actorOne = TestActorRef(Incrementer.props(testProbe.ref),"ActorOne") val actorTwo = TestActorRef(Incrementer.props(testProbe.ref),"ActorTwo") actorOne ! SetActor(actorTwo) actorTwo ! SetActor(actorOne) actorOne ! SendData(1) for ( i <- 1 to 10 ) { testProbe.expectMsg(500 millis, Println(s"$i")) } } }