I have the following actor definition:
class MyActor extends Actor {
override def preStart(): Unit = {
super.preStart()
self ! M1("from M1")
}
def receive = initial("initial state")
def initial(str: String): Receive = {
case m1: M1 =>
self ! M3("from M3")
context.become(active(str))
case m2: M2 => println(m2.str)
}
def active(str: String): Receive = {
case m1: M1 => println(m1.str)
case m3: M3 => println(m3.str)
case str: String => println(s"string in active is ${str}")
}
}
I was under the impression that I could just use sbt to test my actor and I went ahead and did the following in my sbt console:
val f = Await.result(myActor ? M1("hello world"), 10 seconds)
I was left with a Timeout Exception. How can I test this actor? I mean, I just want to see what gets printed out to the console!