Package akka.testkit

Examples of akka.testkit.TestProbe


  @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


  public void stopTest() throws Exception {

    ActorRef workerActor1 = supervisor.underlyingActor().workerActor1;
    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

  @Test
  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
    // lets send a new value and retrieve the same
    supervisor.tell(Integer.valueOf(10));
View Full Code Here

  public void testSupervisorStrategy2() throws Exception {

    ActorRef supervisorActorRef2 = _system.actorOf(new Props(
        SupervisorActor.class), "supervisor2");
   
    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

  }

  @Test
  public void mustBeAbleToCreateActorWIthConstructorParams() {
    ActorRef ref = system.actorOf(Props.create(ActorWithConstructorParams.class, "a", "b", new Integer(17), 18));
    final TestProbe probe = new TestProbe(system);
    probe.send(ref, "get");
    probe.expectMsg("a-b-17-18");
  }
View Full Code Here

  }

  @Test
  public void mustBeAbleToCreateActorWIthBoxedAndUnBoxedConstructorParams() {
    ActorRef ref = system.actorOf(Props.create(ActorWithConstructorParams.class, "a", "b", 17, new Integer(18)));
    final TestProbe probe = new TestProbe(system);
    probe.send(ref, "get");
    probe.expectMsg("a-b-17-18");
  }
View Full Code Here

  }

  @Test
  public void mustBeAbleToCreateActorWIthNullConstructorParams() {
    ActorRef ref = system.actorOf(Props.create(ActorWithConstructorParams.class, "a", null, null, 18));
    final TestProbe probe = new TestProbe(system);
    probe.send(ref, "get");
    probe.expectMsg("a-null-null-18");
  }
View Full Code Here

  @Test
  public void mustBeAbleToCreateActorWIthNullConstructorParams2() {
    // without this Object array wrapper it will not compile: "reference to create is ambiguous"
    ActorRef ref = system.actorOf(Props.create(ActorWithConstructorParams.class, new Object[] { null }));
    final TestProbe probe = new TestProbe(system);
    probe.send(ref, "get");
    probe.expectMsg("null-undefined-0-0");
  }
View Full Code Here

  }

  @Test
  public void mustBeAbleToCreateActorWIthNullConstructorParams3() {
    ActorRef ref = system.actorOf(Props.create(ActorWithConstructorParams.class, "a", null));
    final TestProbe probe = new TestProbe(system);
    probe.send(ref, "get");
    probe.expectMsg("a-null-0-0");
  }
View Full Code Here

  private final ActorSystem system = actorSystemResource.getSystem();

  private void testAStashApi(Props props) {
      ActorRef ref = system.actorOf(props);
      final TestProbe probe = new TestProbe(system);
      probe.send(ref, "Hello");
      probe.send(ref, "Hello2");
      probe.send(ref, "Hello12");
      probe.expectMsg(5);
  }
View Full Code Here

TOP

Related Classes of akka.testkit.TestProbe

Copyright © 2018 www.massapicom. 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.