Docs: TestKit leaking into Java getting started guide (#28793)

This commit is contained in:
Johan Andrén 2020-03-27 10:09:48 +01:00 committed by GitHub
parent f683241c40
commit dc678a6319
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -195,25 +195,28 @@ public class ActorHierarchyExperiments {
} }
// #print-refs // #print-refs
class ActorHierarchyExperimentsTest extends JUnitSuite { class StartingActorHierarchyActors {
@ClassRule public static final TestKitJunitResource testKit = new TestKitJunitResource(); public void showStartAndStopActors() {
Behaviors.setup(
@Test context -> {
public void testStartAndStopActors() { // #start-stop-main
// #start-stop-main ActorRef<String> first = context.spawn(StartStopActor1.create(), "first");
ActorRef<String> first = testKit.spawn(StartStopActor1.create(), "first"); first.tell("stop");
first.tell("stop"); // #start-stop-main
// #start-stop-main return Behaviors.empty();
});
} }
@Test public void showSuperviseActors() {
public void testSuperviseActors() throws Exception { Behaviors.setup(
// #supervise-main context -> {
ActorRef<String> supervisingActor = // #supervise-main
testKit.spawn(SupervisingActor.create(), "supervising-actor"); ActorRef<String> supervisingActor =
supervisingActor.tell("failChild"); context.spawn(SupervisingActor.create(), "supervising-actor");
// #supervise-main supervisingActor.tell("failChild");
Thread.sleep(200); // allow for the println/logging to complete // #supervise-main
return Behaviors.empty();
});
} }
} }