Package akka.actor

Examples of akka.actor.ActorRef.tell()


    }

    @Test
    public void successTest() throws Exception {
        ActorRef bank = _system.actorOf(new Props(BankActor.class));
        bank.tell(new TransferMsg(Float.valueOf("1777")));

        AccountBalance balance = (AccountBalance) Await.result(
                ask(bank, new AccountBalance("XYZ"), 5000),
                Duration.create("5 second"));
View Full Code Here


    @Test
    public void failureTest() throws Exception {
        ActorRef bank = _system.actorOf(new Props(BankActor.class));

        bank.tell(new TransferMsg(Float.valueOf("5500")));

        // sleeping to allow some time for actors to be restarted
        Thread.sleep(4000);

        AccountBalance balance = (AccountBalance) Await.result(
View Full Code Here

    @Test
    public void accountTest() throws Exception {
        ActorRef bank = _system.actorOf(new Props(BankActor.class));

        bank.tell(new AccountDebit(Float.parseFloat("1000")));
        bank.tell(new AccountCredit(Float.parseFloat("1000")));
        bank.tell(new AccountDebit(Float.parseFloat("1000")));
        bank.tell(new AccountDebit(Float.parseFloat("1000")));
        bank.tell(new AccountDebit(Float.parseFloat("3500")));
        bank.tell(new AccountCredit(Float.parseFloat("2500")));
View Full Code Here

  @Test
  public void testEchoActor() {
    ActorRef echoActorRef = _system.actorOf(new Props(EchoActor.class));
    // pass the reference to implicit sender testActor() otherwise
    // message end up in dead mailbox
    echoActorRef.tell("Hi there", super.testActor());
    expectMsg("Hi there");
  }

  @Test
  public void testForwardingActor() {
View Full Code Here

            return new ForwardingActor(testActor());
          }
        }));
    // pass the reference to implicit sender testActor() otherwise
    // message end up in dead mailbox
    forwardingActorRef.tell("test message", super.testActor());
    expectMsg("test message");
  }

  @Test
  public void testSequencingActor() {
View Full Code Here

          }
        }));

    // pass the reference to implicit sender testActor() otherwise
    // message end up in dead mailbox
    sequencingActorRef.tell("do something", super.testActor());

    for (Integer value : headList) {
      expectMsgClass(Integer.class);
    }
    expectMsg("do something");
View Full Code Here

          }
        }));
    // pass the reference to implicit sender testActor() otherwise
    // message end up in dead mailbox
    // first test
    filteringActorRef.tell("test message", super.testActor());
    expectMsg("test message");
    // second test
    filteringActorRef.tell(1, super.testActor());
    expectNoMsg();
  }
View Full Code Here

    // message end up in dead mailbox
    // first test
    filteringActorRef.tell("test message", super.testActor());
    expectMsg("test message");
    // second test
    filteringActorRef.tell(1, super.testActor());
    expectNoMsg();
  }

  /**
   * if you want to test how the Supervisor strategy is working fine
View Full Code Here

    // register the BoomActor with the Supervisor
    final ActorRef child = (ActorRef) Await.result(
        ask(supervisorActorRef1, new Props(BoomActor.class), 5000),
        timeout);

    child.tell(123);

    Assert.assertFalse(child.isTerminated());
  }

  @Test
View Full Code Here

    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));

  }

  @Test
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.