Hi,
I'm trying to test a persistent actor
class ServerManager extends PersistentActor {
override def persistenceId = "ServerManager"
override def receiveRecover: Receive = { case _ => }
override def receiveCommand: Receive = {
case Commands.Server.Watch(address) =>
persist(Events.Server.WatchCreated(address)) { event =>
context.actorOf(Props(classOf[ServerMonitor], event.address),
event.address)
}
case Commands.Server.Unwatch(address) =>
for(child <- context.child(address)) context.stop(child)
}
}
My test class looks like this :
class ServerManagerTest(_system: ActorSystem) extends TestKit(_system) with
ImplicitSender with WordSpecLike with Matchers with BeforeAndAfterAll {
def this() = this(
ActorSystem("TestActorSystem", ConfigFactory.parseString(
"""
|akka.loglevel = "DEBUG"
|akka.persistence.journal.plugin = "in-memory-journal"
|akka.actor.debug {
| receive = on
| autoreceive = on
| lifecycle = on
|}
""".stripMargin))
)
override def afterAll() {
TestKit.shutdownActorSystem(system)
}
trait ServerManagerFixture {
val actorRef = TestActorRef[ServerManager]
}
"A ServerManager" when {
val address = "192.168.1.1"
val cmd = Commands.Server.Watch(address)
s"received '$cmd'" should {
s"have one child named '$address'" in new ServerManagerFixture {
actorRef ! cmd
assert(actorRef.underlyingActor.context.children.size === 1)
assert(actorRef.underlyingActor.context.child(address).isDefined)
}
}
}
}
I put break point on receiveCommand and running test, but it's never
called.
I've
checked
https://github.com/akka/akka/blob/master/akka-persistence/src/test/scala/akka/persistence/PersistentActorSpec.scala
; but I can't find what i'm missing.
If anyone can help : Thanks.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.