fix: using createUnhandledMessageProbe to avoid message delivered before subscription (#31498)

This commit is contained in:
GreyPlane 2022-08-24 14:54:52 +08:00 committed by GitHub
parent d0a84d1043
commit bd9ecc64ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,7 +7,6 @@ package akka.actor.typed.scaladsl
import akka.actor.UnhandledMessage
import akka.actor.testkit.typed.TestKitSettings
import akka.actor.testkit.typed.scaladsl.{ FishingOutcomes, LogCapturing, ScalaTestWithActorTestKit, TestProbe }
import akka.actor.typed.eventstream.EventStream
import akka.actor.typed.{ ActorRef, Behavior }
import org.scalatest.wordspec.AnyWordSpecLike
@ -71,8 +70,7 @@ class ActorContextDelegateSpec extends ScalaTestWithActorTestKit with AnyWordSpe
}
"publish unhandled message to eventStream as UnhandledMessage and switch to delegator behavior" in {
val deadLetters = TestProbe[UnhandledMessage]("probeDeadLetters")
system.eventStream ! EventStream.Subscribe[UnhandledMessage](deadLetters.ref)
val deadLetters = testKit.createUnhandledMessageProbe()
val probe = TestProbe[Event]()
val behv = Behaviors.setup[PingPongCommand] { implicit context =>