JavaTestKit probe = new JavaTestKit(actorSystem); actorSystem.actorOf(Props.create(ForwardingActor.class, probe.getRef()), "myActor");
JavaTestKit actor1Probe = new JavaTestKit(actorSystem); actorSystem.actorOf(Props.create(ForwardingActor.class, actor1Probe.getRef()), "actor1");
new JavaTestKit(system) {{ final JavaTestKit probe = new JavaTestKit(system); // install auto-pilot probe.setAutoPilot(new TestActor.AutoPilot() { public AutoPilot run(ActorRef sender, Object msg) { sender.tell(msg, ActorRef.noSender()); return noAutoPilot(); } }); // first one is replied to directly ... probe.getRef().tell("hello", getRef()); expectMsgEquals("hello"); // ... but then the auto-pilot switched itself off probe.getRef().tell("world", getRef()); expectNoMsg(); }};