我正在编写一个测试用例来测试 akka 演员。但是,我必须在假应用程序之外创建一个单独的 Akka 系统。有没有办法从 FakeApplication 获取 akka 演员系统?
public class ChannelWorkerTest {
private TestActorRef<ChannelWorker> actorRef;
private ActorSystem actorSystem;
@Before
public void initActor() {
actorSystem = ActorSystem.apply();
actorRef = TestActorRef.apply(new Props(ChannelWorker.class), actorSystem);
}
@Test
public void calculatePiFor1() {
running(fakeApplication(TestConf.getConf()), new Runnable() {
public void run() {
TestProbe testProbe = TestProbe.apply(actorSystem);
.....
actorRef.tell(aMessage, testProbe.ref());
}
});
}
@After
public void shutdownActorSystem() {
actorSystem.shutdown();
}
}