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".
344345346347348349350351352353354
}; } @Test public void useBecome() { new JavaTestKit(system) { { ActorRef myActor = system.actorOf(Props.create(HotSwapActor.class)); myActor.tell("foo", getRef()); myActor.tell("bar", getRef()); expectMsgEquals("I am already happy :-)");
386387388389390391392393394395396
//#selection-remote } @Test public void useIdentify() throws Exception { new JavaTestKit(system) { { ActorRef a = system.actorOf(Props.create(MyUntypedActor.class), "another"); ActorRef b = system.actorOf(Props.create(Follower.class, getRef())); expectMsgEquals(a); system.stop(a);
574575576577578579580581582583584
public void noReceiveActor() { EventFilter ex1 = new ErrorFilter(ActorInitializationException.class); EventFilter[] ignoreExceptions = { ex1 }; try { system.eventStream().publish(new TestEvent.Mute(immutableSeq(ignoreExceptions))); new JavaTestKit(system) {{ final ActorRef victim = new EventFilter<ActorRef>(ActorInitializationException.class) { protected ActorRef run() { return system.actorOf(Props.create(NoReceiveActor.class), "victim"); } }.message("Actor behavior has not been set with receive(...)").occurrences(1).exec();
456457458459460461462463464465466
} } @Test public void usePatternsAskPipe() { new JavaTestKit(system) { { ActorRef actorA = system.actorOf(Props.create(MyUntypedActor.class)); ActorRef actorB = system.actorOf(Props.create(MyUntypedActor.class)); ActorRef actorC = getRef();
612613614615616617618619620621622
public void multipleReceiveActor() { EventFilter ex1 = new ErrorFilter(IllegalActorStateException.class); EventFilter[] ignoreExceptions = { ex1 }; try { system.eventStream().publish(new TestEvent.Mute(immutableSeq(ignoreExceptions))); new JavaTestKit(system) {{ new EventFilter<Boolean>(IllegalActorStateException.class) { protected Boolean run() { ActorRef victim = system.actorOf(Props.create(MultipleReceiveActor.class), "victim2"); victim.tell("Foo", getRef()); expectMsgEquals("FOO");
3536373839404142434445
system = null; } @Test public void testBuncherActorBatchesCorrectly() { new JavaTestKit(system) {{ final ActorRef buncher = system.actorOf(Props.create(Buncher.class)); final ActorRef probe = getRef(); buncher.tell(new SetTarget(probe), probe);
6263646566676869707172
}}; } @Test public void testBuncherActorDoesntBatchUninitialized() { new JavaTestKit(system) {{ final ActorRef buncher = system.actorOf(Props.create(Buncher.class)); final ActorRef probe = getRef(); buncher.tell(new Queue(42), probe);
158159160161162163164165166167168
//#logging-fsm @Test public void testLoggingFSM() { new JavaTestKit(system) {{ final ActorRef logger = system.actorOf(Props.create(MyFSM.class)); final ActorRef probe = getRef(); logger.tell(probe, probe);
3031323334353637383940
} @Test public void testSampleActor() { new JavaTestKit(system) {{ final ActorRef subject = system.actorOf(Props.create(SampleActor.class), "sample-actor"); final ActorRef probeRef = getRef(); subject.tell(47.11, probeRef); subject.tell("and no guard in the beginning", probeRef);
128129130131132133134135136137138
//#unit-test-logic } @Test public void demonstrateUsageOfCustomRouter() { new JavaTestKit(system) {{ //#usage-1 for (int n = 1; n <= 10; n++) { system.actorOf(Props.create(Storage.class), "s" + n); }