Package akka.testkit

Examples of akka.testkit.TestProbe.watch()


  @Test
  public void stopTest() throws Exception {

    ActorRef workerActor = supervisor.underlyingActor().childActor;
    TestProbe probe = new TestProbe(_system);
    probe.watch(workerActor);

    supervisor.tell(Long.parseLong("10"));

    probe.expectMsgClass(Terminated.class);
  }
View Full Code Here


    ActorRef workerActor2 = supervisor.underlyingActor().workerActor2;

    TestProbe probe1 = new TestProbe(_system);
    TestProbe probe2 = new TestProbe(_system);
    probe1.watch(workerActor1);
    probe2.watch(workerActor2);

    supervisor.tell(Long.parseLong("10"));

    probe1.expectMsgClass(Terminated.class);
    probe2.expectMsgClass(Terminated.class);
View Full Code Here

  public void stopAndRestartTest() throws Exception {
    TestActorRef<SupervisorActor> supervisor = TestActorRef.apply(
        new Props(SupervisorActor.class), _system);
    ActorRef workerActor = supervisor.underlyingActor().getWorker();
    TestProbe probe = new TestProbe(_system);
    probe.watch(workerActor);
    supervisor.tell("10");
    probe.expectMsgClass(Terminated.class);

    Thread.sleep(2000);
    // the actor should get restarted
View Full Code Here

    final TestProbe probe = new TestProbe(_system);
    // register the BoomActor with the Supervisor
    final ActorRef child = (ActorRef) Await.result(
        ask(supervisorActorRef2, new Props(BoomActor.class), 5000),
        Duration.parse("5 second"));
    probe.watch(child);
    // second check
    child.tell("do something");
    probe.expectMsg(new Terminated(child));

  }
View Full Code Here

    assert Await.result(ask(child, "get", 5000), timeout).equals(0);
    //#restart

    //#stop
    final TestProbe probe = new TestProbe(system);
    probe.watch(child);
    child.tell(new IllegalArgumentException(), ActorRef.noSender());
    probe.expectMsgClass(Terminated.class);
    //#stop

    //#escalate-kill
View Full Code Here

    //#stop

    //#escalate-kill
    child = (ActorRef) Await.result(ask(supervisor,
      Props.create(Child.class), 5000), timeout);
    probe.watch(child);
    assert Await.result(ask(child, "get", 5000), timeout).equals(0);
    child.tell(new Exception(), ActorRef.noSender());
    probe.expectMsgClass(Terminated.class);
    //#escalate-kill
View Full Code Here

    assert Await.result(ask(child, "get", 5000), timeout).equals(0);
    //#restart

    //#stop
    final TestProbe probe = new TestProbe(system);
    probe.watch(child);
    child.tell(new IllegalArgumentException(), ActorRef.noSender());
    probe.expectMsgClass(Terminated.class);
    //#stop

    //#escalate-kill
View Full Code Here

    //#stop

    //#escalate-kill
    child = (ActorRef) Await.result(ask(supervisor,
      Props.create(Child.class), 5000), timeout);
    probe.watch(child);
    assert Await.result(ask(child, "get", 5000), timeout).equals(0);
    child.tell(new Exception(), ActorRef.noSender());
    probe.expectMsgClass(Terminated.class);
    //#escalate-kill
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.