Пример #1
0
 @Test
 public void testingWithoutParent() {
   TestProbe probe = new TestProbe(system);
   ActorRef child = system.actorOf(Props.create(DependentChild.class, probe.ref()));
   probe.send(child, "ping");
   probe.expectMsg("pong");
 }
Пример #2
0
  @Test
  public void fabricatedParentTestsItsChildResponses() throws Exception {
    // didn't put final on these in order to make the parent fit in one line in the html docs
    // #test-fabricated-parent
    TestProbe proxy = new TestProbe(system);
    ActorRef parent = system.actorOf(Props.create(new FabricatedParentCreator(proxy)));

    proxy.send(parent, "ping");
    proxy.expectMsg("pong");
    // #test-fabricated-parent
  }
Пример #3
0
 public void exampleProdActorFactoryFunction() throws Exception {
   // #child-maker-prod
   Function<ActorRefFactory, ActorRef> maker =
       new Function<ActorRefFactory, ActorRef>() {
         @Override
         public ActorRef apply(ActorRefFactory f) throws Exception {
           return f.actorOf(Props.create(Child.class));
         }
       };
   ActorRef parent = system.actorOf(Props.create(GenericDependentParent.class, maker));
   // #child-maker-prod
 }
Пример #4
0
 @Test
 public void testingWithChildProbe() throws Exception {
   final TestProbe probe = new TestProbe(system);
   // #child-maker-test
   Function<ActorRefFactory, ActorRef> maker =
       new Function<ActorRefFactory, ActorRef>() {
         @Override
         public ActorRef apply(ActorRefFactory param) throws Exception {
           return probe.ref();
         }
       };
   ActorRef parent = system.actorOf(Props.create(GenericDependentParent.class, maker));
   // #child-maker-test
   probe.send(parent, "pingit");
   probe.expectMsg("ping");
 }