@Test public void usePipeWithActorSelection() throws Exception { TestProbe probe = new TestProbe(system); ActorSelection selection = system.actorSelection(probe.ref().path()); pipe(Futures.successful("hi!"), system.dispatcher()).to(selection); probe.expectMsg("hi!"); }
public static void startWorker(Address contactAddress) { ActorSystem system = ActorSystem.create(systemName); Set<ActorSelection> initialContacts = new HashSet<ActorSelection>(); initialContacts.add(system.actorSelection(contactAddress + "/user/receptionist")); ActorRef clusterClient = system.actorOf(ClusterClient.defaultProps(initialContacts), "clusterClient"); system.actorOf(Worker.props(clusterClient, Props.create(WorkExecutor.class)), "worker"); }
@Test public void useAskWithActorSelection() throws Exception { ActorRef testActor = system.actorOf(Props.create(JavaAPITestActor.class), "test2"); ActorSelection selection = system.actorSelection("/user/test2"); ActorIdentity id = (ActorIdentity) Await.result(ask(selection, new Identify("yo!"), 3000), Duration.create(3, "seconds")); assertEquals("Ask (Identify) should return the proper ActorIdentity", testActor, id.getRef()); }