+tes #21198 Allow TestActor/TestKit/TestProbe to create child actors
This is useful in at least two scenarios: - Unit testing actors that communicate to their parent directly - Testing re-creating (typically persistent) actors with the same name
This commit is contained in:
parent
4821fb158e
commit
09f2d83e69
8 changed files with 248 additions and 33 deletions
|
|
@ -4,14 +4,16 @@
|
|||
package docs.testkit;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import akka.actor.*;
|
||||
import akka.japi.Creator;
|
||||
import akka.japi.Function;
|
||||
import akka.testkit.AkkaJUnitActorSystemResource;
|
||||
import akka.testkit.JavaTestKit;
|
||||
import akka.testkit.TestActorRef;
|
||||
import akka.testkit.TestProbe;
|
||||
|
||||
import com.typesafe.config.ConfigFactory;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -187,6 +189,17 @@ public class ParentChildTest {
|
|||
}
|
||||
//#test-fabricated-parent-creator
|
||||
|
||||
@Test
|
||||
public void testProbeParentTest() throws Exception {
|
||||
//#test-TestProbe-parent
|
||||
JavaTestKit parent = new JavaTestKit(system);
|
||||
ActorRef child = parent.childActorOf(Props.create(Child.class));
|
||||
|
||||
parent.send(child, "ping");
|
||||
parent.expectMsgEquals("pong");
|
||||
//#test-TestProbe-parent
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fabricatedParentTestsItsChildResponses() throws Exception {
|
||||
// didn't put final on these in order to make the parent fit in one line in the html docs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue