Docs: TestKit leaking into Java getting started guide (#28793)
This commit is contained in:
parent
f683241c40
commit
dc678a6319
1 changed files with 20 additions and 17 deletions
|
|
@ -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 = testKit.spawn(StartStopActor1.create(), "first");
|
ActorRef<String> first = context.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(
|
||||||
|
context -> {
|
||||||
// #supervise-main
|
// #supervise-main
|
||||||
ActorRef<String> supervisingActor =
|
ActorRef<String> supervisingActor =
|
||||||
testKit.spawn(SupervisingActor.create(), "supervising-actor");
|
context.spawn(SupervisingActor.create(), "supervising-actor");
|
||||||
supervisingActor.tell("failChild");
|
supervisingActor.tell("failChild");
|
||||||
// #supervise-main
|
// #supervise-main
|
||||||
Thread.sleep(200); // allow for the println/logging to complete
|
return Behaviors.empty();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue