Exemplo n.º 1
0
 @Test
 public void useWatch() {
   ActorSystem system = ActorSystem.create("MySystem");
   ActorRef myActor = system.actorOf(new Props(WatchActor.class));
   Future<Object> future = Patterns.ask(myActor, "kill", 1000);
   assert Await.result(future, Duration.parse("1 second")).equals("finished");
   system.shutdown();
 }
Exemplo n.º 2
0
  // #crTest
  @Test
  public void countVotesAsIntendedNotAsInFlorida() {
    ActorRef routedActor = system.actorOf(new Props().withRouter(new VoteCountRouter()));
    routedActor.tell(DemocratVote);
    routedActor.tell(DemocratVote);
    routedActor.tell(RepublicanVote);
    routedActor.tell(DemocratVote);
    routedActor.tell(RepublicanVote);
    Timeout timeout = new Timeout(Duration.parse("1 seconds"));
    Future<Object> democratsResult = routedActor.ask(DemocratCountResult, timeout);
    Future<Object> republicansResult = routedActor.ask(RepublicanCountResult, timeout);

    assertEquals(3, Await.result(democratsResult, timeout.duration()));
    assertEquals(2, Await.result(republicansResult, timeout.duration()));
  }