* deprecate intercept
This commit is contained in:
parent
905694be1c
commit
f17bdbe233
30 changed files with 221 additions and 215 deletions
|
|
@ -0,0 +1 @@
|
|||
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.actor.testkit.typed.scaladsl.LoggingTestKit.expect")
|
||||
|
|
@ -54,7 +54,7 @@ import org.slf4j.event.Level
|
|||
mdc.forall { case (key, value) => event.mdc.contains(key) && event.mdc(key) == value } &&
|
||||
custom.forall(f => f(event))
|
||||
|
||||
// loggerName is handled when installing the filter, in `intercept`
|
||||
// loggerName is handled when installing the filter, in `expect`
|
||||
}
|
||||
|
||||
private def messageOrEmpty(event: LoggingEvent): String =
|
||||
|
|
@ -82,7 +82,7 @@ import org.slf4j.event.Level
|
|||
todo > 0
|
||||
}
|
||||
|
||||
override def intercept[T](code: => T)(implicit system: ActorSystem[_]): T = {
|
||||
override def expect[T](code: => T)(implicit system: ActorSystem[_]): T = {
|
||||
val effectiveLoggerName = loggerName.getOrElse("")
|
||||
checkLogback(system)
|
||||
TestAppender.setupTestAppender(effectiveLoggerName)
|
||||
|
|
@ -107,6 +107,13 @@ import org.slf4j.event.Level
|
|||
}
|
||||
}
|
||||
|
||||
override def expect[T](system: ActorSystem[_], code: Supplier[T]): T =
|
||||
expect(code.get())(system)
|
||||
|
||||
// deprecated (renamed to expect)
|
||||
override def intercept[T](code: => T)(implicit system: ActorSystem[_]): T =
|
||||
expect(code)(system)
|
||||
|
||||
private def checkLogback(system: ActorSystem[_]): Unit = {
|
||||
if (!system.dynamicAccess.classIsOnClasspath("ch.qos.logback.classic.spi.ILoggingEvent")) {
|
||||
throw new IllegalStateException("LoggingEventFilter requires logback-classic dependency in classpath.")
|
||||
|
|
@ -150,7 +157,4 @@ import org.slf4j.event.Level
|
|||
override def withCause(newCause: Class[_ <: Throwable]): javadsl.LoggingTestKit =
|
||||
copy(cause = Option(newCause))
|
||||
|
||||
override def expect[T](system: ActorSystem[_], code: Supplier[T]): T =
|
||||
intercept(code.get())(system)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ import org.slf4j.event.Level
|
|||
def matches(event: LoggingEvent): Boolean
|
||||
|
||||
/**
|
||||
* Run the given code block and assert that this filter has
|
||||
* Run the given code block and assert that the criteria of this `LoggingTestKit` has
|
||||
* matched within the configured `akka.actor.testkit.typed.filter-leeway`
|
||||
* as often as requested by its `occurrences` parameter specifies.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.slf4j.event.Level
|
|||
* Number of events the testkit is supposed to match. By default 1.
|
||||
*
|
||||
* When occurrences > 0 it will not look for excess messages that are logged asynchronously
|
||||
* outside (after) the `intercept` thunk and it has already found expected number.
|
||||
* outside (after) the `expect` thunk and it has already found expected number.
|
||||
*
|
||||
* When occurrences is 0 it will look for unexpected matching events, and then it will
|
||||
* also look for excess messages during the configured `akka.actor.testkit.typed.expect-no-message-default`
|
||||
|
|
@ -86,12 +86,22 @@ import org.slf4j.event.Level
|
|||
def matches(event: LoggingEvent): Boolean
|
||||
|
||||
/**
|
||||
* Apply this filter while executing the given code block.
|
||||
* Assert that this filter has matched as often as requested by its
|
||||
* `occurrences` parameter specifies.
|
||||
* Run the given code block and assert that the criteria of this `LoggingTestKit` has
|
||||
* matched within the configured `akka.actor.testkit.typed.filter-leeway`
|
||||
* as often as requested by its `occurrences` parameter specifies.
|
||||
*
|
||||
* Care is taken to remove the filter when the block is finished or aborted.
|
||||
* Care is taken to remove the testkit when the block is finished or aborted.
|
||||
*/
|
||||
def expect[T](code: => T)(implicit system: ActorSystem[_]): T
|
||||
|
||||
/**
|
||||
* Run the given code block and assert that the criteria of this `LoggingTestKit` has
|
||||
* matched within the configured `akka.actor.testkit.typed.filter-leeway`
|
||||
* as often as requested by its `occurrences` parameter specifies.
|
||||
*
|
||||
* Care is taken to remove the testkit when the block is finished or aborted.
|
||||
*/
|
||||
@deprecated("Use except instead.", "2.6.0")
|
||||
def intercept[T](code: => T)(implicit system: ActorSystem[_]): T
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,20 +27,20 @@ class TestAppenderSpec
|
|||
|
||||
"TestAppender and LoggingEventFilter" must {
|
||||
"filter errors without cause" in {
|
||||
LoggingTestKit.error("an error").withOccurrences(2).intercept {
|
||||
LoggingTestKit.error("an error").withOccurrences(2).expect {
|
||||
log.error("an error")
|
||||
log.error("an error")
|
||||
}
|
||||
}
|
||||
|
||||
"filter errors with cause" in {
|
||||
LoggingTestKit.error("err").withCause[TestException].intercept {
|
||||
LoggingTestKit.error("err").withCause[TestException].expect {
|
||||
log.error("err", TestException("an error"))
|
||||
}
|
||||
}
|
||||
|
||||
"filter warnings" in {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(2).intercept {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(2).expect {
|
||||
log.error("an error")
|
||||
log.warn("a warning")
|
||||
log.error("an error")
|
||||
|
|
@ -50,7 +50,7 @@ class TestAppenderSpec
|
|||
|
||||
"find excess messages" in {
|
||||
intercept[AssertionError] {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(2).intercept {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(2).expect {
|
||||
log.error("an error")
|
||||
log.warn("a warning")
|
||||
log.warn("a warning")
|
||||
|
|
@ -73,7 +73,7 @@ class TestAppenderSpec
|
|||
})
|
||||
.withOccurrences(2)
|
||||
.withLoggerName(classOf[AnotherLoggerClass].getName)
|
||||
.intercept {
|
||||
.expect {
|
||||
LoggerFactory.getLogger(classOf[AnotherLoggerClass]).info("Hello from right logger")
|
||||
log.info("Hello wrong logger")
|
||||
LoggerFactory.getLogger(classOf[AnotherLoggerClass]).info("Hello from right logger")
|
||||
|
|
@ -82,13 +82,13 @@ class TestAppenderSpec
|
|||
}
|
||||
|
||||
"find unexpected events withOccurrences(0)" in {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).intercept {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).expect {
|
||||
log.error("an error")
|
||||
log.warn("another warning")
|
||||
}
|
||||
|
||||
intercept[AssertionError] {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).intercept {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).expect {
|
||||
log.error("an error")
|
||||
log.warn("a warning")
|
||||
log.warn("another warning")
|
||||
|
|
@ -96,7 +96,7 @@ class TestAppenderSpec
|
|||
}.getMessage should include("Received 1 excess messages")
|
||||
|
||||
intercept[AssertionError] {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).intercept {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).expect {
|
||||
log.warn("a warning")
|
||||
log.warn("a warning")
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ class TestAppenderSpec
|
|||
"find unexpected async events withOccurrences(0)" in {
|
||||
// expect-no-message-default = 1000 ms
|
||||
intercept[AssertionError] {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).intercept {
|
||||
LoggingTestKit.warn("a warning").withOccurrences(0).expect {
|
||||
Future {
|
||||
Thread.sleep(20)
|
||||
log.warn("a warning")
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with WordSpecL
|
|||
|
||||
val behavior = Behaviors.supervise(internal).onFailure(SupervisorStrategy.restart)
|
||||
val actor = spawn(behavior)
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
actor ! Fail
|
||||
}
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
|
|
@ -203,7 +203,7 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with WordSpecL
|
|||
|
||||
val parentRef = spawn(parent)
|
||||
val childRef = probe.expectMessageType[ChildMade].ref
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
childRef ! Fail
|
||||
}
|
||||
probe.expectMessage(GotChildSignal(PreRestart))
|
||||
|
|
@ -260,7 +260,7 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with WordSpecL
|
|||
val actor = spawn(behavior)
|
||||
actor ! Ping
|
||||
probe.expectMessage(1)
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
actor ! Fail
|
||||
}
|
||||
actor ! Ping
|
||||
|
|
@ -286,7 +286,7 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with WordSpecL
|
|||
val actor = spawn(behavior)
|
||||
actor ! Ping
|
||||
probe.expectMessage(1)
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
actor ! Fail
|
||||
}
|
||||
actor ! Ping
|
||||
|
|
@ -328,7 +328,7 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with WordSpecL
|
|||
probe.expectMessage(Pong)
|
||||
watcher ! Ping
|
||||
probe.expectMessage(Pong)
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
actorToWatch ! Fail
|
||||
}
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
|
|
@ -513,7 +513,7 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with WordSpecL
|
|||
val childRef = probe.expectMessageType[ChildMade].ref
|
||||
actor ! Inert
|
||||
probe.expectMessage(InertEvent)
|
||||
LoggingTestKit.error[DeathPactException].intercept {
|
||||
LoggingTestKit.error[DeathPactException].expect {
|
||||
childRef ! Stop
|
||||
probe.expectMessage(GotChildSignal(PostStop))
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class AskSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCaptur
|
|||
|
||||
LoggingTestKit
|
||||
.error("Exception thrown out of adapter. Stopping myself.")
|
||||
.intercept {
|
||||
.expect {
|
||||
replyRef2 ! 42L
|
||||
}(system)
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class DeferredSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogC
|
|||
Behaviors.stopped
|
||||
}
|
||||
}
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
spawn(behv)
|
||||
probe.expectMessage(Started)
|
||||
probe.expectMessage(Pong)
|
||||
|
|
@ -138,7 +138,7 @@ class DeferredSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogC
|
|||
Behaviors.same
|
||||
}
|
||||
}
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
val ref = spawn(behv)
|
||||
probe.expectTerminated(ref, probe.remainingOrDefault)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ class InterceptSpec extends ScalaTestWithActorTestKit with WordSpecLike with Log
|
|||
val probe = TestProbe[String]()
|
||||
val interceptor = snitchingInterceptor(probe.ref)
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
val ref = spawn(Behaviors.intercept(() => interceptor)(Behaviors.setup[String] { _ =>
|
||||
Behaviors.same[String]
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ class LogMessagesSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref: ActorRef[String] = spawn(behavior)
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path.toString}] received message: Hello").intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path.toString}] received message: Hello").expect {
|
||||
ref ! "Hello"
|
||||
}
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").expect {
|
||||
testKit.stop(ref)
|
||||
}
|
||||
}
|
||||
|
|
@ -41,11 +41,11 @@ class LogMessagesSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref: ActorRef[String] = spawn(behavior)
|
||||
|
||||
LoggingTestKit.info(s"actor [${ref.path}] received message: Hello").intercept {
|
||||
LoggingTestKit.info(s"actor [${ref.path}] received message: Hello").expect {
|
||||
ref ! "Hello"
|
||||
}
|
||||
|
||||
LoggingTestKit.info(s"actor [${ref.path}] received signal: PostStop").intercept {
|
||||
LoggingTestKit.info(s"actor [${ref.path}] received signal: PostStop").expect {
|
||||
testKit.stop(ref)
|
||||
}
|
||||
}
|
||||
|
|
@ -57,11 +57,11 @@ class LogMessagesSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref: ActorRef[String] = spawn(behavior)
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: Hello").intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: Hello").expect {
|
||||
ref ! "Hello"
|
||||
}
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").expect {
|
||||
testKit.stop(ref)
|
||||
}
|
||||
}
|
||||
|
|
@ -72,11 +72,11 @@ class LogMessagesSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref: ActorRef[String] = spawn(behavior)
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: Hello").withOccurrences(0).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: Hello").withOccurrences(0).expect {
|
||||
ref ! "Hello"
|
||||
}
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").withOccurrences(0).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").withOccurrences(0).expect {
|
||||
testKit.stop(ref)
|
||||
}
|
||||
}
|
||||
|
|
@ -88,11 +88,11 @@ class LogMessagesSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref = spawn(behavior)
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: Hello").withMdc(mdc).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: Hello").withMdc(mdc).expect {
|
||||
ref ! "Hello"
|
||||
}
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").withMdc(mdc).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received signal: PostStop").withMdc(mdc).expect {
|
||||
testKit.stop(ref)
|
||||
}
|
||||
}
|
||||
|
|
@ -106,21 +106,21 @@ class LogMessagesSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref2 = spawn(behavior2)
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref2.path}] received message: Hello").withMdc(mdc2).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref2.path}] received message: Hello").withMdc(mdc2).expect {
|
||||
ref2 ! "Hello"
|
||||
}
|
||||
|
||||
val ref1 = spawn(behavior1)
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref1.path}] received message: Hello").withMdc(mdc1).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref1.path}] received message: Hello").withMdc(mdc1).expect {
|
||||
ref1 ! "Hello"
|
||||
}
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref2.path}] received signal: PostStop").withMdc(mdc2).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref2.path}] received signal: PostStop").withMdc(mdc2).expect {
|
||||
testKit.stop(ref2)
|
||||
}
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref1.path}] received signal: PostStop").withMdc(mdc1).intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref1.path}] received signal: PostStop").withMdc(mdc1).expect {
|
||||
testKit.stop(ref1)
|
||||
}
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ class LogMessagesSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref = spawn(behavior)
|
||||
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: 13").intercept {
|
||||
LoggingTestKit.debug(s"actor [${ref.path}] received message: 13").expect {
|
||||
ref.unsafeUpcast[Any] ! 13
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class MailboxSelectorSpec extends ScalaTestWithActorTestKit("""
|
|||
}, MailboxSelector.bounded(2))
|
||||
actor ! "one" // actor will block here
|
||||
actor ! "two"
|
||||
LoggingTestKit.deadLetters().intercept {
|
||||
LoggingTestKit.deadLetters().expect {
|
||||
// one or both of these doesn't fit in mailbox
|
||||
// depending on race with how fast actor consumes
|
||||
actor ! "three"
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
val probe = TestProbe[Event]("evt")
|
||||
val behv = targetBehavior(probe.ref)
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.error[Exc3].intercept {
|
||||
LoggingTestKit.error[Exc3].expect {
|
||||
ref ! Throw(new Exc3)
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
probe.expectTerminated(ref)
|
||||
|
|
@ -326,7 +326,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
val probe = TestProbe[Event]("evt")
|
||||
val behv = Behaviors.supervise(targetBehavior(probe.ref)).onFailure[Throwable](SupervisorStrategy.stop)
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.error[Exc3].intercept {
|
||||
LoggingTestKit.error[Exc3].expect {
|
||||
ref ! Throw(new Exc3)
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
probe.expectTerminated(ref)
|
||||
|
|
@ -340,7 +340,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
targetBehavior(probe.ref)
|
||||
})
|
||||
val behv = Behaviors.supervise(failedSetup).onFailure[Throwable](SupervisorStrategy.stop)
|
||||
LoggingTestKit.error[Exc3].intercept {
|
||||
LoggingTestKit.error[Exc3].expect {
|
||||
spawn(behv)
|
||||
}
|
||||
}
|
||||
|
|
@ -353,12 +353,12 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref = spawn(behv)
|
||||
|
||||
LoggingTestKit.error[IOException].intercept {
|
||||
LoggingTestKit.error[IOException].expect {
|
||||
ref ! Throw(new IOException())
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
||||
LoggingTestKit.error[IllegalArgumentException].intercept {
|
||||
LoggingTestKit.error[IllegalArgumentException].expect {
|
||||
ref ! Throw(new IllegalArgumentException("cat"))
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
}
|
||||
|
|
@ -374,7 +374,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref = spawn(behv)
|
||||
|
||||
LoggingTestKit.error[Exception].intercept {
|
||||
LoggingTestKit.error[Exception].expect {
|
||||
ref ! Throw(new IOException())
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! Ping(1)
|
||||
probe.expectMessage(Pong(1))
|
||||
|
||||
LoggingTestKit.error[IllegalArgumentException].intercept {
|
||||
LoggingTestKit.error[IllegalArgumentException].expect {
|
||||
ref ! Throw(new IllegalArgumentException("cat"))
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -400,7 +400,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val ref = spawn(behv)
|
||||
|
||||
LoggingTestKit.error[Exception].intercept {
|
||||
LoggingTestKit.error[Exception].expect {
|
||||
ref ! Throw(new IOException())
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -408,7 +408,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! Ping(1)
|
||||
probe.expectMessage(Pong(1))
|
||||
|
||||
LoggingTestKit.error[IllegalArgumentException].intercept {
|
||||
LoggingTestKit.error[IllegalArgumentException].expect {
|
||||
ref ! Throw(new IllegalArgumentException("cat"))
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -422,7 +422,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
val probe = TestProbe[Event]("evt")
|
||||
val behv = targetBehavior(probe.ref)
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.error[Exc3].intercept {
|
||||
LoggingTestKit.error[Exc3].expect {
|
||||
ref ! Throw(new Exc3)
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
val probe = TestProbe[Event]("evt")
|
||||
val behv = Behaviors.supervise(targetBehavior(probe.ref)).onFailure[Exc1](SupervisorStrategy.restart)
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.error[Exc3].intercept {
|
||||
LoggingTestKit.error[Exc3].expect {
|
||||
ref ! Throw(new Exc3)
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
}
|
||||
|
|
@ -446,7 +446,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! GetState
|
||||
probe.expectMessage(State(1, Map.empty))
|
||||
|
||||
LoggingTestKit.error[Exc2].intercept {
|
||||
LoggingTestKit.error[Exc2].expect {
|
||||
ref ! Throw(new Exc2)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -465,7 +465,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! GetState
|
||||
probe.expectMessage(State(1, Map.empty))
|
||||
|
||||
LoggingTestKit.error[Exc2].withOccurrences(3).intercept {
|
||||
LoggingTestKit.error[Exc2].withOccurrences(3).expect {
|
||||
ref ! Throw(new Exc2)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
ref ! Throw(new Exc2)
|
||||
|
|
@ -488,7 +488,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! GetState
|
||||
probe.expectMessage(State(1, Map.empty))
|
||||
|
||||
LoggingTestKit.error[Exc2].withOccurrences(3).intercept {
|
||||
LoggingTestKit.error[Exc2].withOccurrences(3).expect {
|
||||
ref ! Throw(new Exc2)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
ref ! Throw(new Exc2)
|
||||
|
|
@ -528,7 +528,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! GetState
|
||||
parentProbe.expectMessageType[State].children.keySet should ===(Set(child1Name, child2Name))
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref ! Throw(new Exc1)
|
||||
parentProbe.expectMessage(ReceivedSignal(PreRestart))
|
||||
ref ! GetState
|
||||
|
|
@ -566,7 +566,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! GetState
|
||||
parentProbe.expectMessageType[State].children.keySet should contain(childName)
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref ! Throw(new Exc1)
|
||||
parentProbe.expectMessage(ReceivedSignal(PreRestart))
|
||||
ref ! GetState
|
||||
|
|
@ -597,7 +597,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
val child2Name = nextName()
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref ! Throw(new Exc1)
|
||||
parentProbe.expectMessage(ReceivedSignal(PreRestart))
|
||||
ref ! GetState
|
||||
|
|
@ -606,7 +606,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! Throw(new Exc1)
|
||||
}
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
slowStop.countDown()
|
||||
childProbe.expectMessage(ReceivedSignal(PostStop)) // child1
|
||||
parentProbe.expectMessageType[State].children.keySet should ===(Set.empty)
|
||||
|
|
@ -651,7 +651,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
.onFailure[RuntimeException](strategy)
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val ref = spawn(behv)
|
||||
slowStop1.countDown()
|
||||
child1Probe.expectMessage(ReceivedSignal(PostStop))
|
||||
|
|
@ -702,12 +702,12 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
throwFromSetup.set(true)
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref ! Throw(new Exc1)
|
||||
parentProbe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
slowStop1.countDown()
|
||||
child1Probe.expectMessage(ReceivedSignal(PostStop))
|
||||
child1Probe.expectMessage(ReceivedSignal(PostStop))
|
||||
|
|
@ -728,7 +728,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! GetState
|
||||
probe.expectMessage(State(1, Map.empty))
|
||||
|
||||
LoggingTestKit.error[Exc2].intercept {
|
||||
LoggingTestKit.error[Exc2].expect {
|
||||
ref ! Throw(new Exc2)
|
||||
ref ! GetState
|
||||
probe.expectMessage(State(1, Map.empty))
|
||||
|
|
@ -746,7 +746,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
probe.expectMessage(State(1, Map.empty))
|
||||
|
||||
// resume
|
||||
LoggingTestKit.error[Exc2].intercept {
|
||||
LoggingTestKit.error[Exc2].expect {
|
||||
ref ! Throw(new Exc2)
|
||||
probe.expectNoMessage()
|
||||
ref ! GetState
|
||||
|
|
@ -754,7 +754,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
|
||||
// restart
|
||||
LoggingTestKit.error[Exc3].intercept {
|
||||
LoggingTestKit.error[Exc3].expect {
|
||||
ref ! Throw(new Exc3)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
ref ! GetState
|
||||
|
|
@ -762,7 +762,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
|
||||
// stop
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref ! Throw(new Exc1)
|
||||
probe.expectMessage(ReceivedSignal(PostStop))
|
||||
}
|
||||
|
|
@ -784,7 +784,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
.onFailure[Exception](strategy)
|
||||
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
startedProbe.expectMessage(Started)
|
||||
ref ! Throw(new Exc1)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
|
|
@ -819,7 +819,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
.onFailure[Exception](strategy)
|
||||
val ref = spawn(behv)
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
startedProbe.expectMessage(Started)
|
||||
ref ! IncrementState
|
||||
ref ! Throw(new Exc1)
|
||||
|
|
@ -835,7 +835,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
probe.expectMessage(State(0, Map.empty))
|
||||
|
||||
// one more time
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref ! IncrementState
|
||||
ref ! Throw(new Exc1)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
|
|
@ -873,8 +873,8 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
.onFailure[Exception](strategy)
|
||||
val ref = spawn(behv)
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[TestException].withOccurrences(2).intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
LoggingTestKit.error[TestException].withOccurrences(2).expect {
|
||||
startedProbe.expectMessage(Started)
|
||||
ref ! Throw(new Exc1)
|
||||
probe.expectTerminated(ref, 3.seconds)
|
||||
|
|
@ -895,7 +895,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
val behv = supervise(targetBehavior(probe.ref)).onFailure[Exc1](strategy)
|
||||
val ref = spawn(behv)
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref ! IncrementState
|
||||
ref ! Throw(new Exc1)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
|
|
@ -908,7 +908,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
probe.expectMessage(State(0, Map.empty))
|
||||
|
||||
// one more time after the reset timeout
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
probe.expectNoMessage(strategy.resetBackoffAfter + 100.millis.dilated)
|
||||
ref ! IncrementState
|
||||
ref ! Throw(new Exc1)
|
||||
|
|
@ -939,7 +939,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
failCount = 1,
|
||||
strategy = SupervisorStrategy.restart) {
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
spawn(behv)
|
||||
}
|
||||
}
|
||||
|
|
@ -947,7 +947,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
"fail to restart when deferred factory throws unhandled" in new FailingUnhandledTestSetup(
|
||||
strategy = SupervisorStrategy.restart) {
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
spawn(behv)
|
||||
}
|
||||
}
|
||||
|
|
@ -955,8 +955,8 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
"fail to resume when deferred factory throws" in new FailingDeferredTestSetup(
|
||||
failCount = 1,
|
||||
strategy = SupervisorStrategy.resume) {
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
spawn(behv)
|
||||
}
|
||||
}
|
||||
|
|
@ -966,7 +966,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
failCount = 1,
|
||||
strategy = SupervisorStrategy.restartWithBackoff(minBackoff = 100.millis.dilated, maxBackoff = 1.second, 0)) {
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
spawn(behv)
|
||||
|
||||
probe.expectMessage(StartFailed)
|
||||
|
|
@ -979,7 +979,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
"fail instead of restart with exponential backoff when deferred factory throws unhandled" in new FailingUnhandledTestSetup(
|
||||
strategy = SupervisorStrategy.restartWithBackoff(minBackoff = 100.millis.dilated, maxBackoff = 1.second, 0)) {
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
spawn(behv)
|
||||
probe.expectMessage(StartFailed)
|
||||
}
|
||||
|
|
@ -989,7 +989,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
failCount = 1,
|
||||
strategy = SupervisorStrategy.restart.withLimit(3, 1.second)) {
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
spawn(behv)
|
||||
|
||||
probe.expectMessage(StartFailed)
|
||||
|
|
@ -1001,8 +1001,8 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
failCount = 20,
|
||||
strategy = SupervisorStrategy.restart.withLimit(2, 1.second)) {
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[TestException].withOccurrences(2).intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
LoggingTestKit.error[TestException].withOccurrences(2).expect {
|
||||
spawn(behv)
|
||||
|
||||
// first one from initial setup
|
||||
|
|
@ -1018,7 +1018,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
"fail instead of restart with limit when deferred factory throws unhandled" in new FailingUnhandledTestSetup(
|
||||
strategy = SupervisorStrategy.restart.withLimit(3, 1.second)) {
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
spawn(behv)
|
||||
probe.expectMessage(StartFailed)
|
||||
}
|
||||
|
|
@ -1029,7 +1029,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
val behv = supervise(setup[Command](ctx => new FailingConstructor(ctx, probe.ref)))
|
||||
.onFailure[Exception](SupervisorStrategy.restart)
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
spawn(behv)
|
||||
probe.expectMessage(Started) // first one before failure
|
||||
}
|
||||
|
|
@ -1074,7 +1074,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
actor ! "ping"
|
||||
probe.expectMessage("pong")
|
||||
|
||||
LoggingTestKit.error[RuntimeException].intercept {
|
||||
LoggingTestKit.error[RuntimeException].expect {
|
||||
// Should be supervised as resume
|
||||
actor ! "boom"
|
||||
}
|
||||
|
|
@ -1122,7 +1122,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
actor ! "ping"
|
||||
probe.expectMessage("pong")
|
||||
|
||||
LoggingTestKit.error[RuntimeException].intercept {
|
||||
LoggingTestKit.error[RuntimeException].expect {
|
||||
// Should be supervised as resume
|
||||
actor ! "boom"
|
||||
}
|
||||
|
|
@ -1166,7 +1166,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
probe.expectMessage("started 1")
|
||||
ref ! "ping"
|
||||
probe.expectMessage("pong 1")
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
ref ! "boom"
|
||||
probe.expectMessage("crashing 1")
|
||||
ref ! "ping"
|
||||
|
|
@ -1178,7 +1178,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
probe.expectMessage("pong 2")
|
||||
LoggingTestKit
|
||||
.error[TestException]
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! "boom" // now we should have replaced supervision with the resuming one
|
||||
probe.expectMessage("crashing 2")
|
||||
}(system)
|
||||
|
|
@ -1211,7 +1211,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
})
|
||||
.onFailure[DeathPactException](SupervisorStrategy.restart))
|
||||
|
||||
LoggingTestKit.error[DeathPactException].intercept {
|
||||
LoggingTestKit.error[DeathPactException].expect {
|
||||
actor ! "boom"
|
||||
val child = probe.expectMessageType[ActorRef[_]]
|
||||
probe.expectTerminated(child, 3.seconds)
|
||||
|
|
@ -1226,7 +1226,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
.supervise(targetBehavior(probe.ref))
|
||||
.onFailure[Exc1](SupervisorStrategy.restart.withLoggingEnabled(true).withLogLevel(Level.INFO))
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.info("exc-1").intercept {
|
||||
LoggingTestKit.info("exc-1").expect {
|
||||
ref ! Throw(new Exc1)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -1238,7 +1238,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
.supervise(targetBehavior(probe.ref))
|
||||
.onFailure[Exc1](SupervisorStrategy.restart.withLoggingEnabled(true).withLogLevel(Level.DEBUG))
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.info("exc-1").withSource(ref.path.toString).withOccurrences(0).intercept {
|
||||
LoggingTestKit.info("exc-1").withSource(ref.path.toString).withOccurrences(0).expect {
|
||||
ref ! Throw(new Exc1)
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -1266,7 +1266,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
ref ! Ping(1)
|
||||
probe.expectMessage(Pong(1))
|
||||
|
||||
LoggingTestKit.error[Exc1].intercept {
|
||||
LoggingTestKit.error[Exc1].expect {
|
||||
ref.unsafeUpcast ! "boom"
|
||||
probe.expectMessage(ReceivedSignal(PreRestart))
|
||||
}
|
||||
|
|
@ -1317,7 +1317,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
.error[IllegalStateException]
|
||||
.withMessageContains("created with wrong ActorContext")
|
||||
.withOccurrences(2) // twice because also logged for PostStop signal
|
||||
.intercept {
|
||||
.expect {
|
||||
wrong ! "boom"
|
||||
}
|
||||
probe.expectTerminated(wrong)
|
||||
|
|
@ -1363,7 +1363,7 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""
|
|||
})
|
||||
.onFailure[TestException](strategy))
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
actor ! "boom"
|
||||
}
|
||||
createTestProbe().expectTerminated(actor, 3.second)
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ class TimerSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
probe.expectMessage(Tock(1))
|
||||
|
||||
val latch = new CountDownLatch(1)
|
||||
LoggingTestKit.error[Exc].intercept {
|
||||
LoggingTestKit.error[Exc].expect {
|
||||
// next Tock(1) is enqueued in mailbox, but should be discarded by new incarnation
|
||||
ref ! SlowThenThrow(latch, new Exc)
|
||||
|
||||
|
|
@ -205,7 +205,7 @@ class TimerSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
|
||||
probe.expectMessage(Tock(2))
|
||||
|
||||
LoggingTestKit.error[Exc].intercept {
|
||||
LoggingTestKit.error[Exc].expect {
|
||||
val latch = new CountDownLatch(1)
|
||||
// next Tock(2) is enqueued in mailbox, but should be discarded by new incarnation
|
||||
ref ! SlowThenThrow(latch, new Exc)
|
||||
|
|
@ -226,7 +226,7 @@ class TimerSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
target(probe.ref, timer, 1)
|
||||
}
|
||||
val ref = spawn(behv)
|
||||
LoggingTestKit.error[Exc].intercept {
|
||||
LoggingTestKit.error[Exc].expect {
|
||||
ref ! Throw(new Exc)
|
||||
probe.expectMessage(GotPostStop(false))
|
||||
}
|
||||
|
|
@ -305,7 +305,7 @@ class TimerSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
}
|
||||
}
|
||||
})
|
||||
LoggingTestKit.info("stopping").intercept {
|
||||
LoggingTestKit.info("stopping").expect {
|
||||
ref ! "stop"
|
||||
}
|
||||
probe.expectTerminated(ref)
|
||||
|
|
@ -344,7 +344,7 @@ class TimerSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
Behaviors.unhandled
|
||||
}
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val ref = spawn(Behaviors.supervise(behv).onFailure[TestException](SupervisorStrategy.restart))
|
||||
ref ! Tick(-1)
|
||||
probe.expectMessage(Tock(-1))
|
||||
|
|
@ -379,7 +379,7 @@ class TimerSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
Behaviors.unhandled
|
||||
}
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val ref = spawn(Behaviors.supervise(behv).onFailure[TestException](SupervisorStrategy.restart))
|
||||
ref ! Tick(-1)
|
||||
probe.expectMessage(Tock(-1))
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class TransformMessagesSpec extends ScalaTestWithActorTestKit with WordSpecLike
|
|||
case s => s.toLowerCase
|
||||
}
|
||||
|
||||
LoggingTestKit.error[ActorInitializationException].intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].expect {
|
||||
val ref = spawn(transform(transform(Behaviors.receiveMessage[String] { _ =>
|
||||
Behaviors.same
|
||||
})))
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class WatchSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
},
|
||||
"supervised-child-parent")
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
parent ! "boom"
|
||||
}
|
||||
probe.expectMessageType[ChildHasFailed].t.cause shouldEqual ex
|
||||
|
|
@ -144,7 +144,7 @@ class WatchSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
}
|
||||
val parent = spawn(behavior, "parent")
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
parent ! "boom"
|
||||
}
|
||||
probe.expectMessageType[ChildHasFailed].t.cause shouldEqual ex
|
||||
|
|
@ -183,8 +183,8 @@ class WatchSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
},
|
||||
"grosso-bosso")
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[DeathPactException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
LoggingTestKit.error[DeathPactException].expect {
|
||||
grossoBosso ! "boom"
|
||||
}
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ class WatchSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
LoggingTestKit
|
||||
.error[IllegalStateException]
|
||||
.withMessageContains("termination message was not overwritten")
|
||||
.intercept {
|
||||
.expect {
|
||||
watcher ! StartWatching(terminator)
|
||||
}
|
||||
// supervisor should have stopped the actor
|
||||
|
|
@ -340,7 +340,7 @@ class WatchSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
LoggingTestKit
|
||||
.error[IllegalStateException]
|
||||
.withMessageContains("termination message was not overwritten")
|
||||
.intercept {
|
||||
.expect {
|
||||
watcher ! StartWatchingWith(terminator, CustomTerminationMessage2)
|
||||
}
|
||||
// supervisor should have stopped the actor
|
||||
|
|
@ -352,7 +352,7 @@ class WatchSpec extends ScalaTestWithActorTestKit with WordSpecLike with LogCapt
|
|||
LoggingTestKit
|
||||
.error[IllegalStateException]
|
||||
.withMessageContains("termination message was not overwritten")
|
||||
.intercept {
|
||||
.expect {
|
||||
watcher ! StartWatchingWith(terminator, CustomTerminationMessage)
|
||||
}
|
||||
// supervisor should have stopped the actor
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class ActorContextAskSpec
|
|||
}
|
||||
}
|
||||
|
||||
LoggingTestKit.error[NotImplementedError].withMessageContains("Pong").intercept {
|
||||
LoggingTestKit.error[NotImplementedError].withMessageContains("Pong").expect {
|
||||
spawn(snitch)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
}
|
||||
|
||||
val actor = LoggingTestKit.info("Started").intercept(spawn(behavior, "the-actor"))
|
||||
val actor = LoggingTestKit.info("Started").expect(spawn(behavior, "the-actor"))
|
||||
|
||||
LoggingTestKit.info("got message Hello").intercept(actor ! "Hello")
|
||||
LoggingTestKit.info("got message Hello").expect(actor ! "Hello")
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
|
||||
val actor =
|
||||
LoggingTestKit.info("Started").withLoggerName(classOf[AnotherLoggerClass].getName).intercept {
|
||||
LoggingTestKit.info("Started").withLoggerName(classOf[AnotherLoggerClass].getName).expect {
|
||||
spawn(behavior, "the-other-actor")
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
.withLoggerName(classOf[AnotherLoggerClass].getName)
|
||||
.withOccurrences(2)
|
||||
.intercept {
|
||||
.expect {
|
||||
actor ! "Hello"
|
||||
LoggerFactory.getLogger(classOf[ActorLoggingSpec]).debug("Hello from other logger")
|
||||
actor ! "Hello"
|
||||
|
|
@ -122,7 +122,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
false
|
||||
})
|
||||
|
||||
eventFilter.intercept(spawn(Behaviors.setup[String] { context =>
|
||||
eventFilter.expect(spawn(Behaviors.setup[String] { context =>
|
||||
context.log.info("Started")
|
||||
|
||||
Behaviors.receive { (context, message) =>
|
||||
|
|
@ -141,7 +141,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
false
|
||||
})
|
||||
|
||||
eventFilter.intercept(spawn(WhereTheBehaviorIsDefined.behavior, "the-actor-with-object"))
|
||||
eventFilter.expect(spawn(WhereTheBehaviorIsDefined.behavior, "the-actor-with-object"))
|
||||
}
|
||||
|
||||
"contain the abstract behavior class name where the first log was called" in {
|
||||
|
|
@ -152,7 +152,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
false
|
||||
})
|
||||
|
||||
eventFilter.intercept {
|
||||
eventFilter.expect {
|
||||
spawn(Behaviors.setup[String](context => new BehaviorWhereTheLoggerIsUsed(context)), "the-actor-with-behavior")
|
||||
}
|
||||
}
|
||||
|
|
@ -163,7 +163,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
event.marker.map(_.getName) == Option(marker.getName)
|
||||
}
|
||||
.withOccurrences(5)
|
||||
.intercept(spawn(Behaviors.setup[Any] { context =>
|
||||
.expect(spawn(Behaviors.setup[Any] { context =>
|
||||
context.log.debug(marker, "whatever")
|
||||
context.log.info(marker, "whatever")
|
||||
context.log.warn(marker, "whatever")
|
||||
|
|
@ -179,7 +179,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
event.throwable == Option(cause)
|
||||
}
|
||||
.withOccurrences(2)
|
||||
.intercept(spawn(Behaviors.setup[Any] { context =>
|
||||
.expect(spawn(Behaviors.setup[Any] { context =>
|
||||
context.log.warn("whatever", cause)
|
||||
context.log.warn(marker, "whatever", cause)
|
||||
Behaviors.stopped
|
||||
|
|
@ -195,7 +195,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
true // any is fine, we're just after the right count of statements reaching the listener
|
||||
}
|
||||
.withOccurrences(36)
|
||||
.intercept({
|
||||
.expect({
|
||||
spawn(Behaviors.setup[String] {
|
||||
context =>
|
||||
context.log.debug("message")
|
||||
|
|
@ -246,7 +246,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
|
||||
"use Slf4jLogger from akka-slf4j automatically" in {
|
||||
LoggingTestKit.info("via Slf4jLogger").intercept {
|
||||
LoggingTestKit.info("via Slf4jLogger").expect {
|
||||
// this will log via classic eventStream
|
||||
system.toClassic.log.info("via Slf4jLogger")
|
||||
}
|
||||
|
|
@ -263,11 +263,11 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
}
|
||||
val actor =
|
||||
LoggingTestKit.info("Starting up").withMdc(Map(ActorMdc.TagsKey -> "tag1,tag2")).intercept {
|
||||
LoggingTestKit.info("Starting up").withMdc(Map(ActorMdc.TagsKey -> "tag1,tag2")).expect {
|
||||
spawn(behavior, ActorTags("tag1", "tag2"))
|
||||
}
|
||||
|
||||
LoggingTestKit.info("Got message").withMdc(Map(ActorMdc.TagsKey -> "tag1,tag2")).intercept {
|
||||
LoggingTestKit.info("Got message").withMdc(Map(ActorMdc.TagsKey -> "tag1,tag2")).expect {
|
||||
actor ! "ping"
|
||||
}
|
||||
}
|
||||
|
|
@ -343,12 +343,12 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
.info("Starting")
|
||||
// not counting for example "akkaSource", but it shouldn't have any other entries
|
||||
.withCustom(logEvent => logEvent.mdc.keysIterator.forall(_.startsWith("akka")))
|
||||
.intercept {
|
||||
.expect {
|
||||
spawn(behaviors)
|
||||
}
|
||||
|
||||
// mdc on message
|
||||
LoggingTestKit.info("Got message!").withMdc(Map("static" -> "1", "txId" -> "1", "first" -> "true")).intercept {
|
||||
LoggingTestKit.info("Got message!").withMdc(Map("static" -> "1", "txId" -> "1", "first" -> "true")).expect {
|
||||
ref ! Message(1, "first")
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
.info("Got message!")
|
||||
.withMdc(Map("static" -> "1", "txId" -> "2"))
|
||||
.withCustom(event => !event.mdc.contains("first"))
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! Message(2, "second")
|
||||
}
|
||||
}
|
||||
|
|
@ -379,7 +379,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
.info("message")
|
||||
.withMdc(Map("outermost" -> "true"))
|
||||
.withCustom(event => !event.mdc.contains("innermost"))
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! "message"
|
||||
}
|
||||
}
|
||||
|
|
@ -397,7 +397,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
|
||||
val ref = spawn(Behaviors.withMdc(Map("hasMdc" -> "true"))(behavior))
|
||||
LoggingTestKit.info("message").withMdc(Map("hasMdc" -> "true")).intercept {
|
||||
LoggingTestKit.info("message").withMdc(Map("hasMdc" -> "true")).expect {
|
||||
ref ! "message"
|
||||
}
|
||||
|
||||
|
|
@ -406,7 +406,7 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
LoggingTestKit
|
||||
.info("message")
|
||||
.withMdc(Map("hasMdc" -> "true")) // original mdc should stay
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! "message"
|
||||
}
|
||||
|
||||
|
|
@ -429,14 +429,14 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
}
|
||||
|
||||
val ref = spawn(behavior)
|
||||
LoggingTestKit.info("message").withMdc(Map("mdc-version" -> "1")).intercept {
|
||||
LoggingTestKit.info("message").withMdc(Map("mdc-version" -> "1")).expect {
|
||||
ref ! "message"
|
||||
}
|
||||
ref ! "new-mdc"
|
||||
LoggingTestKit
|
||||
.info("message")
|
||||
.withMdc(Map("mdc-version" -> "2")) // mdc should have been replaced
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! "message"
|
||||
}
|
||||
|
||||
|
|
@ -454,8 +454,8 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
|
||||
// mdc on message
|
||||
val ref = spawn(behavior)
|
||||
LoggingTestKit.info("first").withMdc(Map("mdc" -> "outer")).intercept {
|
||||
LoggingTestKit.info("second").withMdc(Map("mdc" -> "inner-outer")).intercept {
|
||||
LoggingTestKit.info("first").withMdc(Map("mdc" -> "outer")).expect {
|
||||
LoggingTestKit.info("second").withMdc(Map("mdc" -> "inner-outer")).expect {
|
||||
ref ! Message(1, "first")
|
||||
}
|
||||
}
|
||||
|
|
@ -479,12 +479,12 @@ class ActorLoggingSpec extends ScalaTestWithActorTestKit("""
|
|||
// log from setup
|
||||
// can't use LoggingEventFilter.withMdc here because the actorPathStr isn't know yet
|
||||
val ref =
|
||||
LoggingTestKit.info("Starting").withCustom(event => event.mdc("akkaSource") == actorPathStr.get).intercept {
|
||||
LoggingTestKit.info("Starting").withCustom(event => event.mdc("akkaSource") == actorPathStr.get).expect {
|
||||
spawn(behavior)
|
||||
}
|
||||
|
||||
// on message
|
||||
LoggingTestKit.info("Got message!").withMdc(Map("akkaSource" -> actorPathStr.get)).withOccurrences(10).intercept {
|
||||
LoggingTestKit.info("Got message!").withMdc(Map("akkaSource" -> actorPathStr.get)).withOccurrences(10).expect {
|
||||
(1 to 10).foreach { n =>
|
||||
ref ! Message(n, s"msg-$n")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,52 +24,52 @@ class LoggerOpsSpec extends ScalaTestWithActorTestKit with WordSpecLike with Log
|
|||
"LoggerOps" must {
|
||||
|
||||
"provide extension method for 2 arguments" in {
|
||||
LoggingTestKit.info("[template a b]").intercept {
|
||||
LoggingTestKit.info("[template a b]").expect {
|
||||
log.info2("[template {} {}]", "a", "b")
|
||||
}
|
||||
LoggingTestKit.info("[template a 2]").intercept {
|
||||
LoggingTestKit.info("[template a 2]").expect {
|
||||
log.info2("[template {} {}]", "a", 2)
|
||||
}
|
||||
LoggingTestKit.info("[template 1 2]").intercept {
|
||||
LoggingTestKit.info("[template 1 2]").expect {
|
||||
log.info2("[template {} {}]", 1, 2)
|
||||
}
|
||||
LoggingTestKit.info("[template 1 b]").intercept {
|
||||
LoggingTestKit.info("[template 1 b]").expect {
|
||||
log.info2("[template {} {}]", 1, "b")
|
||||
}
|
||||
LoggingTestKit.info("[template a Value2(2)]").intercept {
|
||||
LoggingTestKit.info("[template a Value2(2)]").expect {
|
||||
log.info2("[template {} {}]", "a", Value2(2))
|
||||
}
|
||||
LoggingTestKit.info("[template Value1(1) Value1(1)]").intercept {
|
||||
LoggingTestKit.info("[template Value1(1) Value1(1)]").expect {
|
||||
log.info2("[template {} {}]", Value1(1), Value1(1))
|
||||
}
|
||||
LoggingTestKit.info("[template Value1(1) Value2(2)]").intercept {
|
||||
LoggingTestKit.info("[template Value1(1) Value2(2)]").expect {
|
||||
log.info2("[template {} {}]", Value1(1), Value2(2))
|
||||
}
|
||||
}
|
||||
|
||||
"provide extension method for vararg arguments" in {
|
||||
LoggingTestKit.info("[template a b c]").intercept {
|
||||
LoggingTestKit.info("[template a b c]").expect {
|
||||
log.infoN("[template {} {} {}]", "a", "b", "c")
|
||||
}
|
||||
LoggingTestKit.info("[template a b 3]").intercept {
|
||||
LoggingTestKit.info("[template a b 3]").expect {
|
||||
log.infoN("[template {} {} {}]", "a", "b", 3)
|
||||
}
|
||||
LoggingTestKit.info("[template a 2 c]").intercept {
|
||||
LoggingTestKit.info("[template a 2 c]").expect {
|
||||
log.infoN("[template {} {} {}]", "a", 2, "c")
|
||||
}
|
||||
LoggingTestKit.info("[template 1 2 3]").intercept {
|
||||
LoggingTestKit.info("[template 1 2 3]").expect {
|
||||
log.infoN("[template {} {} {}]", 1, 2, 3)
|
||||
}
|
||||
LoggingTestKit.info("[template 1 b c]").intercept {
|
||||
LoggingTestKit.info("[template 1 b c]").expect {
|
||||
log.infoN("[template {} {} {}]", 1, "b", "c")
|
||||
}
|
||||
LoggingTestKit.info("[template a Value2(2) Value3(3)]").intercept {
|
||||
LoggingTestKit.info("[template a Value2(2) Value3(3)]").expect {
|
||||
log.infoN("[template {} {} {}]", "a", Value2(2), Value3(3))
|
||||
}
|
||||
LoggingTestKit.info("[template Value1(1) Value1(1) Value1(1)]").intercept {
|
||||
LoggingTestKit.info("[template Value1(1) Value1(1) Value1(1)]").expect {
|
||||
log.infoN("[template {} {} {}]", Value1(1), Value1(1), Value1(1))
|
||||
}
|
||||
LoggingTestKit.info("[template Value1(1) Value2(2) Value3(3)]").intercept {
|
||||
LoggingTestKit.info("[template Value1(1) Value2(2) Value3(3)]").expect {
|
||||
log.infoN("[template {} {} {}]", Value1(1), Value2(2), Value3(3))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ class MessageAdapterSpec
|
|||
}
|
||||
|
||||
// Not expecting "Exception thrown out of adapter. Stopping myself"
|
||||
LoggingTestKit.error[TestException].withMessageContains("boom").intercept {
|
||||
LoggingTestKit.error[TestException].withMessageContains("boom").expect {
|
||||
spawn(snitch)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class RoutersSpec extends ScalaTestWithActorTestKit("""
|
|||
Behaviors.same
|
||||
}))
|
||||
|
||||
LoggingTestKit.debug("Pool child stopped").withOccurrences(2).intercept {
|
||||
LoggingTestKit.debug("Pool child stopped").withOccurrences(2).expect {
|
||||
pool ! "stop"
|
||||
pool ! "stop"
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ class RoutersSpec extends ScalaTestWithActorTestKit("""
|
|||
Behaviors.stopped
|
||||
}))
|
||||
|
||||
LoggingTestKit.info("Last pool child stopped, stopping pool").intercept {
|
||||
LoggingTestKit.info("Last pool child stopped, stopping pool").expect {
|
||||
(0 to 3).foreach { _ =>
|
||||
pool ! "stop"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ class UnstashingSpec extends ScalaTestWithActorTestKit with WordSpecLike with Lo
|
|||
LoggingTestKit
|
||||
.error[TestException]
|
||||
.withMessageContains("unstash-fail")
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! "unstash"
|
||||
probe.expectMessage("unstashing-0")
|
||||
probe.expectMessage("unstashing-1")
|
||||
|
|
@ -452,7 +452,7 @@ class UnstashingSpec extends ScalaTestWithActorTestKit with WordSpecLike with Lo
|
|||
LoggingTestKit
|
||||
.error[TestException]
|
||||
.withMessageContains("Supervisor RestartSupervisor saw failure: unstash-fail")
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! "unstash"
|
||||
// when childLatch is defined this be stashed in the internal stash of the RestartSupervisor
|
||||
// because it's waiting for child to stop
|
||||
|
|
@ -535,7 +535,7 @@ class UnstashingSpec extends ScalaTestWithActorTestKit with WordSpecLike with Lo
|
|||
LoggingTestKit
|
||||
.error[TestException]
|
||||
.withMessageContains("Supervisor ResumeSupervisor saw failure: unstash-fail")
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! "unstash"
|
||||
ref ! "get-current"
|
||||
|
||||
|
|
|
|||
|
|
@ -304,7 +304,7 @@ class AdapterSpec extends WordSpec with Matchers with BeforeAndAfterAll with Log
|
|||
// only stop supervisorStrategy
|
||||
LoggingTestKit
|
||||
.error[AdapterSpec.ThrowIt3.type]
|
||||
.intercept {
|
||||
.expect {
|
||||
typedRef ! "supervise-restart"
|
||||
probe.expectMsg("ok")
|
||||
}(system.toTyped)
|
||||
|
|
@ -317,7 +317,7 @@ class AdapterSpec extends WordSpec with Matchers with BeforeAndAfterAll with Log
|
|||
|
||||
LoggingTestKit
|
||||
.error[ActorInitializationException]
|
||||
.intercept {
|
||||
.expect {
|
||||
typedRef ! "supervise-start-fail"
|
||||
probe.expectMsg("terminated")
|
||||
}(system.toTyped)
|
||||
|
|
@ -343,7 +343,7 @@ class AdapterSpec extends WordSpec with Matchers with BeforeAndAfterAll with Log
|
|||
val throwMsg = "sad panda"
|
||||
LoggingTestKit
|
||||
.error("sad panda")
|
||||
.intercept {
|
||||
.expect {
|
||||
system.spawnAnonymous(unhappyTyped(throwMsg))
|
||||
Thread.sleep(1000)
|
||||
}(system.toTyped)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ object LoggingDocExamples {
|
|||
// implicit ActorSystem is needed, but that is given by ScalaTestWithActorTestKit
|
||||
//implicit val system: ActorSystem[_]
|
||||
|
||||
LoggingTestKit.info("Received message").intercept {
|
||||
LoggingTestKit.info("Received message").expect {
|
||||
ref ! Message("hello")
|
||||
}
|
||||
//#test-logging
|
||||
|
|
@ -134,7 +134,7 @@ object LoggingDocExamples {
|
|||
}
|
||||
}
|
||||
.withOccurrences(2)
|
||||
.intercept {
|
||||
.expect {
|
||||
ref ! Message("hellö")
|
||||
ref ! Message("hejdå")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class RecoveryPermitterSpec extends ScalaTestWithActorTestKit(s"""
|
|||
|
||||
val stopProbe = createTestProbe[ActorRef[Command]]()
|
||||
val parent =
|
||||
LoggingTestKit.error("Exception during recovery.").intercept {
|
||||
LoggingTestKit.error("Exception during recovery.").expect {
|
||||
spawn(Behaviors.setup[Command](ctx => {
|
||||
val persistentActor =
|
||||
ctx.spawnAnonymous(persistentBehavior("p3", p3, p3, throwOnRecovery = true))
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
"A typed persistent actor (failures)" must {
|
||||
|
||||
"signal RecoveryFailure when replay fails" in {
|
||||
LoggingTestKit.error[JournalFailureException].intercept {
|
||||
LoggingTestKit.error[JournalFailureException].expect {
|
||||
val probe = TestProbe[String]()
|
||||
val excProbe = TestProbe[Throwable]()
|
||||
spawn(failingPersistentActor(PersistenceId.ofUniqueId("fail-recovery"), probe.ref, {
|
||||
|
|
@ -159,7 +159,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
probe.expectMessage("malicious")
|
||||
probe.expectMessage("persisted")
|
||||
|
||||
LoggingTestKit.error[JournalFailureException].intercept {
|
||||
LoggingTestKit.error[JournalFailureException].expect {
|
||||
// start again and then the event handler will throw
|
||||
spawn(failingPersistentActor(pid, probe.ref, {
|
||||
case (_, RecoveryFailed(t)) =>
|
||||
|
|
@ -173,7 +173,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
|
||||
"fail recovery if exception from RecoveryCompleted signal handler" in {
|
||||
val probe = TestProbe[String]()
|
||||
LoggingTestKit.error[JournalFailureException].intercept {
|
||||
LoggingTestKit.error[JournalFailureException].expect {
|
||||
spawn(
|
||||
Behaviors
|
||||
.supervise(failingPersistentActor(
|
||||
|
|
@ -252,7 +252,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
}
|
||||
|
||||
"stop (default supervisor strategy) if command handler throws" in {
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val probe = TestProbe[String]()
|
||||
val behav = failingPersistentActor(PersistenceId.ofUniqueId("wrong-command-1"), probe.ref)
|
||||
val c = spawn(behav)
|
||||
|
|
@ -263,7 +263,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
}
|
||||
|
||||
"restart supervisor strategy if command handler throws" in {
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val probe = TestProbe[String]()
|
||||
val behav = Behaviors
|
||||
.supervise(failingPersistentActor(PersistenceId.ofUniqueId("wrong-command-2"), probe.ref))
|
||||
|
|
@ -276,7 +276,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
}
|
||||
|
||||
"stop (default supervisor strategy) if side effect callback throws" in {
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val probe = TestProbe[String]()
|
||||
val behav = failingPersistentActor(PersistenceId.ofUniqueId("wrong-command-3"), probe.ref)
|
||||
val c = spawn(behav)
|
||||
|
|
@ -291,7 +291,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
|
||||
"stop (default supervisor strategy) if signal handler throws" in {
|
||||
case object SomeSignal extends Signal
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val probe = TestProbe[String]()
|
||||
val behav = failingPersistentActor(PersistenceId.ofUniqueId("wrong-signal-handler"), probe.ref, {
|
||||
case (_, SomeSignal) => throw TestException("from signal")
|
||||
|
|
@ -304,7 +304,7 @@ class EventSourcedBehaviorFailureSpec
|
|||
}
|
||||
|
||||
"not accept wrong event, before persisting it" in {
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val probe = TestProbe[String]()
|
||||
val behav = failingPersistentActor(PersistenceId.ofUniqueId("wrong-event-2"), probe.ref)
|
||||
val c = spawn(behav)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class EventSourcedBehaviorRecoveryTimeoutSpec
|
|||
LoggingTestKit
|
||||
.error[JournalFailureException]
|
||||
.withMessageRegex("Exception during recovery.*Replay timed out")
|
||||
.intercept {
|
||||
.expect {
|
||||
val replaying = spawn(testBehavior(pid, probe.ref))
|
||||
|
||||
// initial read highest
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ class EventSourcedBehaviorSpec
|
|||
}
|
||||
|
||||
"fail after recovery timeout" in {
|
||||
LoggingTestKit.error("Exception during recovery from snapshot").intercept {
|
||||
LoggingTestKit.error("Exception during recovery from snapshot").expect {
|
||||
val c = spawn(
|
||||
Behaviors.setup[Command](ctx =>
|
||||
counter(ctx, nextPid)
|
||||
|
|
@ -522,7 +522,7 @@ class EventSourcedBehaviorSpec
|
|||
c ! StopIt
|
||||
probe.expectTerminated(c)
|
||||
|
||||
LoggingTestKit.error[TestException].intercept {
|
||||
LoggingTestKit.error[TestException].expect {
|
||||
val c2 = spawn(Behaviors.setup[Command](counter(_, pid)))
|
||||
c2 ! Fail
|
||||
probe.expectTerminated(c2) // should fail
|
||||
|
|
@ -534,17 +534,11 @@ class EventSourcedBehaviorSpec
|
|||
PersistenceId.ofUniqueId(null)
|
||||
}
|
||||
val probe = TestProbe[AnyRef]
|
||||
LoggingTestKit
|
||||
.error[ActorInitializationException]
|
||||
.withMessageContains("persistenceId must not be null")
|
||||
.intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].withMessageContains("persistenceId must not be null").expect {
|
||||
val ref = spawn(Behaviors.setup[Command](counter(_, persistenceId = PersistenceId.ofUniqueId(null))))
|
||||
probe.expectTerminated(ref)
|
||||
}
|
||||
LoggingTestKit
|
||||
.error[ActorInitializationException]
|
||||
.withMessageContains("persistenceId must not be null")
|
||||
.intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].withMessageContains("persistenceId must not be null").expect {
|
||||
val ref = spawn(Behaviors.setup[Command](counter(_, persistenceId = null)))
|
||||
probe.expectTerminated(ref)
|
||||
}
|
||||
|
|
@ -555,10 +549,7 @@ class EventSourcedBehaviorSpec
|
|||
PersistenceId.ofUniqueId("")
|
||||
}
|
||||
val probe = TestProbe[AnyRef]
|
||||
LoggingTestKit
|
||||
.error[ActorInitializationException]
|
||||
.withMessageContains("persistenceId must not be empty")
|
||||
.intercept {
|
||||
LoggingTestKit.error[ActorInitializationException].withMessageContains("persistenceId must not be empty").expect {
|
||||
val ref = spawn(Behaviors.setup[Command](counter(_, persistenceId = PersistenceId.ofUniqueId(""))))
|
||||
probe.expectTerminated(ref)
|
||||
}
|
||||
|
|
@ -571,7 +562,7 @@ class EventSourcedBehaviorSpec
|
|||
LoggingTestKit
|
||||
.error[ActorInitializationException]
|
||||
.withMessageContains("Default journal plugin is not configured")
|
||||
.intercept {
|
||||
.expect {
|
||||
val ref = testkit2.spawn(Behaviors.setup[Command](counter(_, nextPid())))
|
||||
val probe = testkit2.createTestProbe()
|
||||
probe.expectTerminated(ref)
|
||||
|
|
@ -588,7 +579,7 @@ class EventSourcedBehaviorSpec
|
|||
LoggingTestKit
|
||||
.error[ActorInitializationException]
|
||||
.withMessageContains("Journal plugin [missing] configuration doesn't exist")
|
||||
.intercept {
|
||||
.expect {
|
||||
val ref = testkit2.spawn(Behaviors.setup[Command](counter(_, nextPid()).withJournalPluginId("missing")))
|
||||
val probe = testkit2.createTestProbe()
|
||||
probe.expectTerminated(ref)
|
||||
|
|
@ -609,7 +600,7 @@ class EventSourcedBehaviorSpec
|
|||
try {
|
||||
LoggingTestKit
|
||||
.warn("No default snapshot store configured")
|
||||
.intercept {
|
||||
.expect {
|
||||
val ref = testkit2.spawn(Behaviors.setup[Command](counter(_, nextPid())))
|
||||
val probe = testkit2.createTestProbe[State]()
|
||||
// verify that it's not terminated
|
||||
|
|
@ -633,7 +624,7 @@ class EventSourcedBehaviorSpec
|
|||
LoggingTestKit
|
||||
.error[ActorInitializationException]
|
||||
.withMessageContains("Snapshot store plugin [missing] configuration doesn't exist")
|
||||
.intercept {
|
||||
.expect {
|
||||
val ref = testkit2.spawn(Behaviors.setup[Command](counter(_, nextPid()).withSnapshotPluginId("missing")))
|
||||
val probe = testkit2.createTestProbe()
|
||||
probe.expectTerminated(ref)
|
||||
|
|
|
|||
|
|
@ -542,7 +542,7 @@ class EventSourcedBehaviorStashSpec
|
|||
c ! "start-stashing"
|
||||
|
||||
val limit = system.settings.config.getInt("akka.persistence.typed.stash-capacity")
|
||||
LoggingTestKit.warn("Stash buffer is full, dropping message").intercept {
|
||||
LoggingTestKit.warn("Stash buffer is full, dropping message").expect {
|
||||
(0 to limit).foreach { n =>
|
||||
c ! s"cmd-$n" // limit triggers overflow
|
||||
}
|
||||
|
|
@ -590,7 +590,7 @@ class EventSourcedBehaviorStashSpec
|
|||
|
||||
LoggingTestKit
|
||||
.error[StashOverflowException]
|
||||
.intercept {
|
||||
.expect {
|
||||
val limit = system.settings.config.getInt("akka.persistence.typed.stash-capacity")
|
||||
(0 to limit).foreach { n =>
|
||||
c ! s"cmd-$n" // limit triggers overflow
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ class LoggerSourceSpec
|
|||
// one test case leaks to another, the actual log class is what is tested in each individual case
|
||||
|
||||
"log from setup" in {
|
||||
LoggingTestKit.info("recovery-completed").intercept {
|
||||
eventFilterFor("setting-up-behavior").intercept {
|
||||
LoggingTestKit.info("recovery-completed").expect {
|
||||
eventFilterFor("setting-up-behavior").expect {
|
||||
spawn(behavior)
|
||||
}
|
||||
}
|
||||
|
|
@ -57,8 +57,8 @@ class LoggerSourceSpec
|
|||
}
|
||||
|
||||
"log from recovery completed" in {
|
||||
LoggingTestKit.info("setting-up-behavior").intercept {
|
||||
eventFilterFor("recovery-completed").intercept {
|
||||
LoggingTestKit.info("setting-up-behavior").expect {
|
||||
eventFilterFor("recovery-completed").expect {
|
||||
spawn(behavior)
|
||||
}
|
||||
}
|
||||
|
|
@ -69,8 +69,8 @@ class LoggerSourceSpec
|
|||
.withLogLevel(Level.INFO)
|
||||
.withMessageRegex("(setting-up-behavior|recovery-completed|event-received)")
|
||||
.withOccurrences(3)
|
||||
.intercept {
|
||||
eventFilterFor("command-received").intercept {
|
||||
.expect {
|
||||
eventFilterFor("command-received").expect {
|
||||
spawn(behavior) ! "cmd"
|
||||
}
|
||||
}
|
||||
|
|
@ -81,8 +81,8 @@ class LoggerSourceSpec
|
|||
.withLogLevel(Level.INFO)
|
||||
.withMessageRegex("(setting-up-behavior|recovery-completed|command-received)")
|
||||
.withOccurrences(3)
|
||||
.intercept {
|
||||
eventFilterFor("event-received").intercept {
|
||||
.expect {
|
||||
eventFilterFor("event-received").expect {
|
||||
spawn(behavior) ! "cmd"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class OptionalSnapshotStoreSpec extends ScalaTestWithActorTestKit(s"""
|
|||
|
||||
"Persistence extension" must {
|
||||
"initialize properly even in absence of configured snapshot store" in {
|
||||
LoggingTestKit.warn("No default snapshot store configured").intercept {
|
||||
LoggingTestKit.warn("No default snapshot store configured").expect {
|
||||
val stateProbe = TestProbe[State]()
|
||||
spawn(persistentBehavior(stateProbe))
|
||||
stateProbe.expectNoMessage()
|
||||
|
|
@ -62,8 +62,8 @@ class OptionalSnapshotStoreSpec extends ScalaTestWithActorTestKit(s"""
|
|||
}
|
||||
|
||||
"fail if PersistentActor tries to saveSnapshot without snapshot-store available" in {
|
||||
LoggingTestKit.error("No snapshot store configured").intercept {
|
||||
LoggingTestKit.warn("Failed to save snapshot").intercept {
|
||||
LoggingTestKit.error("No snapshot store configured").expect {
|
||||
LoggingTestKit.warn("Failed to save snapshot").expect {
|
||||
val stateProbe = TestProbe[State]()
|
||||
val persistentActor = spawn(persistentBehavior(stateProbe))
|
||||
persistentActor ! AnyCommand
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue