我正在編寫測試用例來測試akka actor。但是,我必須在假應用程序之外創建一個單獨的Akka系統。有沒有辦法從FakeApplication獲得akka actor系統?從Java中的FakeApplication播放2.0訪問播放的默認Akka actor系統
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();
}
}