Package akka.testkit

Examples of akka.testkit.TestProbe.ref()


  //#demo-transition

  @Test
  public void demonstrateUsage() {
    final TestProbe probe = TestProbe.apply(system);
    final ActorRef target = probe.ref();
    final ActorRef parent = system.actorOf(Props.create(ProxyParent.class, target.path()));
    parent.tell("hello", null);
    probe.expectMsg("world!");
  }
View Full Code Here


  @Test
  public void demonstrateTransitions() {
    final ActorRef target = TestProbe.apply(system).ref();
    final ActorRef parent = system.actorOf(Props.create(ProxyTransitionParent.class, target.path()));
    final TestProbe probe = TestProbe.apply(system);
    parent.tell("hello", probe.ref());
    probe.expectMsg("done");
  }
}
View Full Code Here

  @org.junit.Test
  public void mustBunch() {
    final ActorRef buncher = system.actorOf(Props.create(MyFSM.class));
    final TestProbe probe = new TestProbe(system);
    buncher.tell(new SetTarget(probe.ref()), ActorRef.noSender());
    buncher.tell(new Queue(1), ActorRef.noSender());
    buncher.tell(new Queue(2), ActorRef.noSender());
    buncher.tell(flush, ActorRef.noSender());
    buncher.tell(new Queue(3), ActorRef.noSender());
    final Batch b = probe.expectMsgClass(Batch.class);
View Full Code Here

  //#test-dependentparent-generic

  @Test
  public void testingWithoutParent() {
    TestProbe probe = new TestProbe(system);
    ActorRef child = system.actorOf(Props.create(DependentChild.class, probe.ref()));
    probe.send(child, "ping");
    probe.expectMsg("pong");
  }

  @Test
View Full Code Here

  public void testingWithChildProbe() throws Exception {
    final TestProbe probe = new TestProbe(system);
    //#child-maker-test
    Function<ActorRefFactory, ActorRef> maker = new Function<ActorRefFactory, ActorRef>() {
      @Override public ActorRef apply(ActorRefFactory param) throws Exception {
        return probe.ref();
      }
    };
    ActorRef parent = system.actorOf(Props.create(GenericDependentParent.class, maker));
    //#child-maker-test
    probe.send(parent, "pingit");
View Full Code Here

    }

    @Test
    public void usePipe() throws Exception {
        TestProbe probe = new TestProbe(system);
        pipe(Futures.successful("ho!"), system.dispatcher()).to(probe.ref());
        probe.expectMsg("ho!");
    }

    @Test
    public void usePipeWithActorSelection() throws Exception {
View Full Code Here

    }

    @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!");
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.