2016-01-21 28 views

回答

3
// Initialize the actor and a probe for the actor 
val probe = TestProbe() 
val act = system.actorOf(Props[MyActor], "name") 

// send messages to the actor to change state 
// Validate that the state has changed 

// Send a message to terminate the actor 
act ! PoisonPill 

// wait for the actor to shutdown 
probe.watch(act) 
probe.expectTerminated(act) 

// Initialize a new probe and a new instance of the actor, with the assumption 
// that the actor has the same persistence id as the initial one. 
// That actor should now be in the same state as before. 

val probeTwo = TestProbe() 
val rehydrated = system.actorOf(Props[MyActor], "name") 

// Validate the state of the actor. 
// Todo: Put your validation checks here 

以下是关于test actors的一些有用信息。

相关问题