I have a actor hierarchy which I would like to test for error scenarios - actually test a applied supervisors strategies. I need to modify an actor's receive method - for a message to fail the actor. I found a stackable trait pattern but cannot make it work. My code follows:
trait FailActor extends Actor {
abstract override def receive = LoggingReceive {
fail.orElse(super.receive)
}
def fail:Receive = {
case "fail" => throw new RuntimeException("Test")
}
}
class AddressTranslatorFailActor(storage: ActorRef) extends AddressTranslatorActor(storage) with FailActor
And in the test passing this failing actor:
val probe = TestProbe()
val addressServiceProps = Props {
new AddressServiceActor {
override def translateAddressProps = classOf[AddressTranslatorFailActor]
}
}
where AddressService acctor is defined as follows:
class AddressServiceActor extends Actor with ActorLogging {
def translateAddressProps: Class[_<:AddressTranslatorActor] = classOf[AddressTranslatorActor]
...
But still getting the "fail" message un-handeled. Any hints?