Package akka.actor

Examples of akka.actor.Props


  }

  @Test
  public void testTwo() throws Exception {
    TestActorRef<TickTock> actorRef = TestActorRef.apply(new Props(
        TickTock.class), _system);

    String result = (String) Await.result(ask(actorRef, new Tick("msg"), 5000),
        Duration.parse("5 second"));
View Full Code Here


    Assert.assertEquals("processed the tick message", result);
  }

  @Test
  public void testThree() throws Exception {
    TestActorRef<TickTock> actorRef = TestActorRef.apply(new Props(
        TickTock.class), _system);
    try {
      actorRef.receive("do something");
      //should not reach here
      Assert.fail();
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");
  }
View Full Code Here

    expectMsg("Hi there");
  }

  @Test
  public void testForwardingActor() {
    ActorRef forwardingActorRef = _system.actorOf(new Props(
        new UntypedActorFactory() {
          public UntypedActor create() {
            return new ForwardingActor(testActor());
          }
        }));
View Full Code Here

    for (int i = 0; i < randomHead; i++)
      headList.add(i);
    for (int i = 1; i < randomTail; i++)
      tailList.add(i);

    ActorRef sequencingActorRef = _system.actorOf(new Props(
        new UntypedActorFactory() {
          public UntypedActor create() {
            return new SequencingActor(testActor(), headList,
                tailList);
          }
View Full Code Here

    expectNoMsg();
  }

  @Test
  public void testFilteringActor() {
    ActorRef filteringActorRef = _system.actorOf(new Props(
        new UntypedActorFactory() {
          public UntypedActor create() {
            return new FilteringActor(testActor());
          }
        }));
View Full Code Here

   * if you want to test how the Supervisor strategy is working fine
   */
  @Test
  public void testSupervisorStrategy1() throws Exception {

    ActorRef supervisorActorRef1 = _system.actorOf(new Props(
        SupervisorActor.class), "supervisor1");

    Duration timeout = Duration.parse("5 second");
    // 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());
View Full Code Here

  }

  @Test
  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 testBoomActor() {
    final TestActorRef child = TestActorRef.apply(
        new Props(BoomActor.class), _system);
    try {
      child.receive("do something");
      // should not reach here
      Assert.assertTrue(false);
    } catch (IllegalArgumentException e) {
View Full Code Here

  public static void main(String[] args) throws Exception {

    ActorSystem _system = ActorSystem.create("MapReduceApp");
   
    ActorRef master = _system.actorOf(new Props(MasterActor.class),"master");
   
    master.tell("The quick brown fox tried to jump over the lazy dog and fell on the dog");
    master.tell("Dog is man's best friend");
    master.tell("Dog and Fox belong to the same family");
   
View Full Code Here

TOP

Related Classes of akka.actor.Props

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.