scala - Akka - test supervision strategy -


i have following scenario: parent supervisor actor creates child each message using factory (function) passed in constructor.

class supervisoractor(childactormaker: actorreffactory => actorref)   extends actor actorlogging{    def receive: receive = {      case "testthis" =>       val childactor = childactormaker(context)       childactor!"messageforchild"   }    override val supervisorstrategy =     oneforonestrategy() {       case _ => stop    } }  class childactor extends actor  {    def receive:receive = {       case _ => /** whatever **/    } } 

in test override child receive force exception. expectation child actor stopped every time because of supervision strategy set.

"when child actor throws exception supervisor actor " should " " +     " stop it" in {      val childactorref = testactorref(new childactor() {       override def receive = {         case msg: string => throw new illegalargumentexception("kaboom")       }     })     watch(childactorref)      val maker = (_: actorreffactory) => childactorref     val supervisoractorref = system.actorof(props(new supervisoractor(maker)))      supervisoractorref!"testthis"      expectterminated(childactorref, 1.second) } 

i expect child actor stoped because of supervisorstrategy stop. instead error:

java.lang.assertionerror: assertion failed: timeout (1 second) during expectmsg: terminated 

any idea of why happening? thank you

it seems childactorref not created supervisoractorref's context (i mean actorcontext of supervisoractor created in test code). childactor(childactorref) not child of supervisoractor(supervisoractorref) in test code. that's why supervisor strategy of supervisoractor doesn't serve purpose.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -