Я пытаюсь проверить своих актеров с помощью Actor discovery следующим образом:
class DetectorSpec extends BddSpec {
private val sap = new SapMock()
.withExposedPorts(8080)
.waitingFor(Wait.forHttp("/"))
private val kafka = new KafkaContainer("5.2.1")
sap.start()
kafka.start()
override def afterAll(): Unit = {
sap.stop()
kafka.stop()
}
private def withKafkaAndSapOnline(testCode: TestInbox[ServerEvent] => Future[Assertion])
: Future[Assertion] = {
val config = ConfigFactory.parseString(
s"""
kafka {
servers = "${kafka.getBootstrapServers}"
}
sap {
server = "ws://${sap.getContainerIpAddress}:${sap.getMappedPort(8080)}"
}""")
val system = ActorSystem(DetectorSupervisor.create(), "testSystem1", config)
val inbox = TestInbox[ServerEvent]()
system.receptionist ! Receptionist.Register(ServerStateKey, inbox.ref)
complete {
testCode(inbox)
} lastly {
system.terminate()
}
}
feature("Detect Kafka and SAP availability") {
info("As a technical user, I want to be notified in real time, if Kafka and SAP is up and running or not.")
scenario("SAP and Kafka are available") {
withKafkaAndSapOnline { inbox =>
Given("I am waiting for the current state message")
When("I am receive the state message")
Then("it should contain `SAP and Kafka are online`")
Future {
inbox.receiveMessage() should be(ServerOnlineApproved)
}
}
}
}
}
Когда я начинаю тестирование, у меня появляется следующее сообщение об ошибке:
[ERROR] [06/30/2019 22:15:07.643] [testSystem3-akka.actor.default-dispatcher-3] [akka://testSystem3/system/receptionist] only adapted untyped ActorRefs permissible (Actor[akka.actor.typed.inbox://anonymous/inbox#-233829306] of class akka.actor.testkit.typed.internal.FunctionRef)
akka.actor.ActorInitializationException: akka://testSystem3/system/receptionist/$a: exception during creation
at akka.actor.ActorInitializationException$.apply(Actor.scala:202)
at akka.actor.ActorCell.create(ActorCell.scala:696)
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:547)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:569)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:293)
at akka.dispatch.Mailbox.run(Mailbox.scala:228)
at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.UnsupportedOperationException: only adapted untyped ActorRefs permissible (Actor[akka.actor.typed.inbox://anonymous/inbox#-233829306] of class akka.actor.testkit.typed.internal.FunctionRef)
at akka.actor.typed.internal.adapter.ActorRefAdapter$.toUntyped(ActorRefAdapter.scala:55)
at akka.actor.typed.internal.adapter.ActorContextAdapter.watch(ActorContextAdapter.scala:99)
at akka.actor.typed.internal.receptionist.LocalReceptionist$.$anonfun$behavior$2(LocalReceptionist.scala:64)
at akka.actor.typed.Behavior$DeferredBehavior$$anon$1.apply(Behavior.scala:264)
at akka.actor.typed.Behavior$.start(Behavior.scala:331)
at akka.actor.typed.internal.adapter.ActorAdapter.preStart(ActorAdapter.scala:238)
at akka.actor.Actor.aroundPreStart(Actor.scala:550)
at akka.actor.Actor.aroundPreStart$(Actor.scala:550)
at akka.actor.typed.internal.adapter.ActorAdapter.aroundPreStart(ActorAdapter.scala:51)
at akka.actor.ActorCell.create(ActorCell.scala:676)
... 9 more
Проблема наверняка:
system.receptionist ! Receptionist.Register(ServerStateKey, inbox.ref)
Но что я делаю не так?