Merge pull request #20107 from akka/wip-20027-LoggingReceiveSpec-patriknw

harden LoggingReceiveSpec, #20027
This commit is contained in:
Patrik Nordwall 2016-03-22 15:11:44 +01:00
commit c828bf3a40

View file

@ -91,22 +91,18 @@ class LoggingReceiveSpec extends WordSpec with BeforeAndAfterAll {
val name = actor.path.toString val name = actor.path.toString
actor ! "buh" actor ! "buh"
within(1 second) {
expectMsg(Logging.Debug(actor.path.toString, actor.underlyingActor.getClass, expectMsg(Logging.Debug(actor.path.toString, actor.underlyingActor.getClass,
"received handled message buh from " + self)) "received handled message buh from " + self))
expectMsg("x") expectMsg("x")
}
actor ! "becomenull" actor ! "becomenull"
within(500 millis) {
actor ! "bah" actor ! "bah"
expectMsgPF() { expectMsgPF() {
case UnhandledMessage("bah", testActor, `actor`) true case UnhandledMessage("bah", testActor, `actor`) true
} }
} }
} }
}
"not duplicate logging" in { "not duplicate logging" in {
new TestKit(appLogging) with ImplicitSender { new TestKit(appLogging) with ImplicitSender {
@ -117,13 +113,11 @@ class LoggingReceiveSpec extends WordSpec with BeforeAndAfterAll {
}) })
}) })
actor ! "buh" actor ! "buh"
within(1 second) {
expectMsg(Logging.Debug(actor.path.toString, actor.underlyingActor.getClass, expectMsg(Logging.Debug(actor.path.toString, actor.underlyingActor.getClass,
"received handled message buh from " + self)) "received handled message buh from " + self))
expectMsg("x") expectMsg("x")
} }
} }
}
} }
@ -139,10 +133,11 @@ class LoggingReceiveSpec extends WordSpec with BeforeAndAfterAll {
}) })
val name = actor.path.toString val name = actor.path.toString
actor ! PoisonPill actor ! PoisonPill
expectMsgPF() { fishForMessage(hint = "received AutoReceiveMessage Envelope(PoisonPill") {
case Logging.Debug(`name`, _, msg: String) if msg startsWith "received AutoReceiveMessage Envelope(PoisonPill" true case Logging.Debug(`name`, _, msg: String) if msg startsWith "received AutoReceiveMessage Envelope(PoisonPill" true
case _ false
} }
awaitCond(actor.isTerminated, 100 millis) awaitCond(actor.isTerminated)
} }
} }
@ -182,12 +177,13 @@ class LoggingReceiveSpec extends WordSpec with BeforeAndAfterAll {
supervisor watch actor supervisor watch actor
fishForMessage(hint = "now watched by") { fishForMessage(hint = "now watched by") {
case Logging.Debug(`aname`, `sclass`, msg: String) if msg.startsWith("now watched by") true case Logging.Debug(`aname`, `sclass`, msg: String) if msg.startsWith("now watched by") true
case _ false case m false
} }
supervisor unwatch actor supervisor unwatch actor
expectMsgPF(hint = "no longer watched by") { fishForMessage(hint = "no longer watched by") {
case Logging.Debug(`aname`, `sclass`, msg: String) if msg.startsWith("no longer watched by") case Logging.Debug(`aname`, `sclass`, msg: String) if msg.startsWith("no longer watched by") true
case _ false
} }
} }
} }