/** * Have the testActor watch someone (i.e. * <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** Have the testActor watch someone (i.e. <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** Have the testActor watch someone (i.e. <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** * Have the testActor watch someone (i.e. * <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** * Have the testActor watch someone (i.e. * <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** * Have the testActor watch someone (i.e. * <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** * Have the testActor watch someone (i.e. * <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** * Have the testActor watch someone (i.e. * <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** * Have the testActor watch someone (i.e. * <code>getContext().getWatch(...)</code> ). */ public ActorRef watch(ActorRef ref) { return p.watch(ref); }
/** * Same as {@link JavaTestKit#watch(ActorRef)}. */ public ActorRef watch(final ActorRef actorRef) { return testProbe.watch(actorRef); }
ActorSystem system = ActorSystem.create("x"); ActorRef victim = TestProbe.apply(system).ref(); TestProbe probe = TestProbe.apply(system); probe.watch(victim); ActorRef killer = system.actorOf(Props.create(Killer.class, victim)); killer.tell("kill!", ActorRef.noSender()); probe.expectMsgClass(Terminated.class);
@Test public void testRecoveryAfterRestartSaveSnapshotFail() { system.stop(mockedActor); mockedActor = system.actorOf(MockedActor.props(id, initialBehavior)); probe.watch(mockedActor); probe.expectMsgClass(MockedSnapshotStore.LoadRequest.class); probe.reply(Optional.empty()); probe.expectMsgClass(MockedSnapshotStore.SaveRequest.class); probe.reply(new RuntimeException("save failed")); probe.expectMsgClass(MockedSnapshotStore.DeleteByMetadataRequest.class); probe.expectTerminated(mockedActor, TIMEOUT); }
@Test public void testRecoveryAfterRestartDeleteSnapshotsFail() { system.stop(mockedActor); mockedActor = system.actorOf(MockedActor.props(id, initialBehavior)); probe.watch(mockedActor); probe.expectMsgClass(MockedSnapshotStore.LoadRequest.class); probe.reply(Optional.empty()); probe.expectMsgClass(MockedSnapshotStore.SaveRequest.class); probe.reply(Void.TYPE); probe.expectMsgClass(MockedSnapshotStore.DeleteByCriteriaRequest.class); probe.reply(new RuntimeException("delete failed")); //actor shouldn't terminate probe.expectNoMessage(); }
@Test public void testRecoveryAfterRestartFrontendIdMismatch() { system.stop(mockedActor); //start actor again mockedActor = system.actorOf(MockedActor.props(id, initialBehavior)); probe.expectMsgClass(MockedSnapshotStore.LoadRequest.class); //offer snapshot with incorrect client id final SnapshotMetadata metadata = saveRequest.getMetadata(); final FrontendIdentifier anotherFrontend = FrontendIdentifier.create(MemberName.forName("another"), FrontendType.forName("type-2")); final ClientIdentifier incorrectClientId = ClientIdentifier.create(anotherFrontend, 0); probe.watch(mockedActor); probe.reply(Optional.of(new SelectedSnapshot(metadata, incorrectClientId))); //actor should be stopped probe.expectTerminated(mockedActor, TIMEOUT); }