true
If no timeout is given, take it from the innermost enclosing Within block.
Within
Note that the timeout is scaled using Duration.dilated, which uses the configuration entry "akka.test.timefactor".
2526272829303132333435
system.awaitTermination(Duration.create("10 seconds")); } @Test public void testSetGreeter() { new JavaTestKit(system) {{ final TestActorRef<HelloAkkaJava.Greeter> greeter = TestActorRef.create(system, Props.create(HelloAkkaJava.Greeter.class), "greeter1"); greeter.tell(new HelloAkkaJava.WhoToGreet("testkit"), getTestActor());
3738394041424344454647
}}; } @Test public void testGetGreeter() { new JavaTestKit(system) {{ final ActorRef greeter = system.actorOf(Props.create(HelloAkkaJava.Greeter.class), "greeter2"); greeter.tell(new HelloAkkaJava.WhoToGreet("testkit"), getTestActor()); greeter.tell(new HelloAkkaJava.Greet(), getTestActor());
60616263646566676869
@Before public void setUp() throws Exception { system = ActorSystem.create("test-system"); messageProbe = new JavaTestKit(system); watchingProbe = new JavaTestKit(system); before(); }
39404142434445
@PostConstruct public void initialize() { factory = new CdiAwareCreatorFactory(beanManager); system = ActorSystem.create("System"); probe = new JavaTestKit(system); }
367368369370371372373374375376377
//#dispatchers } @Test public void demonstrateBroadcast() { new JavaTestKit(system) {{ ActorRef router = system.actorOf(new RoundRobinPool(5).props( Props.create(Echo.class))); //#broadcastDavyJonesWarning router.tell(new Broadcast("Watch out for Davy Jones' locker"), getTestActor()); //#broadcastDavyJonesWarning
379380381382383384385386387388389
}}; } @Test public void demonstratePoisonPill() { new JavaTestKit(system) {{ ActorRef router = watch(system.actorOf(new RoundRobinPool(5).props( Props.create(Echo.class)))); //#poisonPill router.tell(PoisonPill.getInstance(), getTestActor()); //#poisonPill
391392393394395396397398399400401
}}; } @Test public void demonstrateBroadcastPoisonPill() { new JavaTestKit(system) {{ ActorRef router = watch(system.actorOf(new RoundRobinPool(5).props( Props.create(Echo.class)))); //#broadcastPoisonPill router.tell(new Broadcast(PoisonPill.getInstance()), getTestActor()); //#broadcastPoisonPill
403404405406407408409410411412413
}}; } @Test public void demonstrateKill() { new JavaTestKit(system) {{ ActorRef router = watch(system.actorOf(new RoundRobinPool(5).props( Props.create(Echo.class)))); //#kill router.tell(Kill.getInstance(), getTestActor()); //#kill
415416417418419420421422423424425
}}; } @Test public void demonstrateBroadcastKill() { new JavaTestKit(system) {{ ActorRef router = watch(system.actorOf(new RoundRobinPool(5).props( Props.create(Echo.class)))); //#broadcastKill router.tell(new Broadcast(Kill.getInstance()), getTestActor()); //#broadcastKill
145146147148149150151152153154155
private final ActorSystem system = actorSystemResource.getSystem(); @Test public void testConnection() { new JavaTestKit(system) { { @SuppressWarnings("unused") final ActorRef server = system.actorOf(Props.create(Server.class, getRef()), "server1"); final InetSocketAddress listen = expectMsgClass(Bound.class).localAddress(); final ActorRef client = system.actorOf(Props.create(Client.class, listen, getRef()), "client1");