diff --git a/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala b/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala index 0f22f6abcd..ec225f67b3 100644 --- a/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/event/EventBusSpec.scala @@ -4,10 +4,7 @@ package akka.event -import scala.concurrent.duration._ - import com.typesafe.config.{ Config, ConfigFactory } -import language.postfixOps import org.scalatest.BeforeAndAfterEach import akka.actor.{ Actor, ActorRef, ActorSystem, PoisonPill, Props } @@ -273,7 +270,7 @@ class ActorEventBusSpec(conf: Config) extends EventBusSpec("ActorEventBus", conf private def expectUnsubscribedByUnsubscriber(p: TestProbe, a: ActorRef): Unit = { val expectedMsg = s"actor $a has terminated, unsubscribing it from $bus" - p.fishForMessage(1 second, hint = expectedMsg) { + p.fishForMessage(hint = expectedMsg) { case Logging.Debug(_, _, msg) if msg.equals(expectedMsg) => true case _ => false } @@ -281,7 +278,7 @@ class ActorEventBusSpec(conf: Config) extends EventBusSpec("ActorEventBus", conf private def expectUnregisterFromUnsubscriber(p: TestProbe, a: ActorRef): Unit = { val expectedMsg = s"unregistered watch of $a in $bus" - p.fishForMessage(1 second, hint = expectedMsg) { + p.fishForMessage(hint = expectedMsg) { case Logging.Debug(_, _, msg) if msg.equals(expectedMsg) => true case _ => false } diff --git a/akka-actor-tests/src/test/scala/akka/event/EventStreamSpec.scala b/akka-actor-tests/src/test/scala/akka/event/EventStreamSpec.scala index d7f68078b9..65fcdb85f4 100644 --- a/akka-actor-tests/src/test/scala/akka/event/EventStreamSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/event/EventStreamSpec.scala @@ -7,7 +7,6 @@ package akka.event import scala.concurrent.duration._ import com.typesafe.config.ConfigFactory -import language.postfixOps import akka.actor._ import akka.testkit.{ AkkaSpec, GHExcludeTest, TestProbe } @@ -82,7 +81,7 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { bus.subscribe(testActor, classOf[M]) bus.publish(M(42)) - within(1 second) { + within(1.second) { expectMsg(M(42)) bus.unsubscribe(testActor) bus.publish(M(13)) @@ -126,7 +125,7 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { bus.startDefaultLoggers(impl) bus.publish(SetTarget(testActor)) expectMsg("OK") - within(2 seconds) { + within(2.seconds) { import Logging._ verifyLevel(bus, InfoLevel) bus.setLogLevel(WarningLevel) @@ -144,7 +143,7 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { val b2 = new B3 val c = new C val bus = new EventStream(system, false) - within(2 seconds) { + within(2.seconds) { bus.subscribe(testActor, classOf[B3]) should ===(true) bus.publish(c) bus.publish(b2) @@ -202,7 +201,7 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { es.publish(tm2) (a1.expectMsgType[AT]: AT) should ===(tm2) (a2.expectMsgType[BT]: BT) should ===(tm2) - a3.expectNoMessage(1 second) + a3.expectNoMessage(1.second) (a4.expectMsgType[CCATBT]: CCATBT) should ===(tm2) es.unsubscribe(a1.ref, classOf[AT]) should ===(true) es.unsubscribe(a2.ref, classOf[BT]) should ===(true) @@ -224,7 +223,7 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { es.publish(tm2) (a1.expectMsgType[AT]: AT) should ===(tm2) (a2.expectMsgType[BT]: BT) should ===(tm2) - a3.expectNoMessage(1 second) + a3.expectNoMessage(1.second) (a4.expectMsgType[CCATBT]: CCATBT) should ===(tm2) es.unsubscribe(a1.ref, classOf[AT]) should ===(true) es.unsubscribe(a2.ref, classOf[BT]) should ===(true) @@ -277,7 +276,7 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { es.subscribe(a1.ref, classOf[AT]) should ===(true) es.publish(tm1) (a1.expectMsgType[AT]: AT) should ===(tm1) - a2.expectNoMessage(1 second) + a2.expectNoMessage(1.second) es.subscribe(a2.ref, classOf[BTT]) should ===(true) es.publish(tm1) (a1.expectMsgType[AT]: AT) should ===(tm1) @@ -308,7 +307,7 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { es.publish(tm) - a1.expectNoMessage(1 second) + a1.expectNoMessage(1.second) a2.expectMsg(tm) } finally { shutdown(sys) @@ -398,17 +397,17 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { es.subscribe(a2.ref, classOf[A]) es.subscribe(a2.ref, classOf[T]) - fishForDebugMessage(a1, s"watching ${a2.ref}", 1 second) - fishForDebugMessage(a1, s"watching ${a2.ref}", 1 second) // the unsubscriber "starts to watch" each time, as watching is idempotent + fishForDebugMessage(a1, s"watching ${a2.ref}") + fishForDebugMessage(a1, s"watching ${a2.ref}") // the unsubscriber "starts to watch" each time, as watching is idempotent es.unsubscribe(a2.ref, classOf[A]) should equal(true) fishForDebugMessage(a1, s"unsubscribing ${a2.ref} from channel class akka.event.EventStreamSpec$$A") - a1.expectNoMessage(1 second) + a1.expectNoMessage(1.second) es.unsubscribe(a2.ref, classOf[T]) should equal(true) fishForDebugMessage(a1, s"unsubscribing ${a2.ref} from channel interface akka.event.EventStreamSpec$$T") fishForDebugMessage(a1, s"unwatching ${a2.ref}, since has no subscriptions") - a1.expectNoMessage(1 second) + a1.expectNoMessage(1.second) es.unsubscribe(a2.ref, classOf[T]) should equal(false) @@ -428,8 +427,8 @@ class EventStreamSpec extends AkkaSpec(EventStreamSpec.config) { msg.foreach(expectMsg(_)) } - private def fishForDebugMessage(a: TestProbe, messagePrefix: String, max: Duration = 3 seconds): Unit = { - a.fishForMessage(max, hint = "expected debug message prefix: " + messagePrefix) { + private def fishForDebugMessage(a: TestProbe, messagePrefix: String): Unit = { + a.fishForMessage(hint = "expected debug message prefix: " + messagePrefix) { case Logging.Debug(_, _, msg: String) if msg.startsWith(messagePrefix) => true case _ => false } diff --git a/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala b/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala index d1aac2fd54..90255fdc80 100644 --- a/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/event/LoggerSpec.scala @@ -155,7 +155,7 @@ class LoggerSpec extends AnyWordSpec with Matchers { system.log.error("Danger! Danger!") // since logging is asynchronous ensure that it propagates if (shouldLog) { - probe.fishForMessage(0.5.seconds.dilated) { + probe.fishForMessage() { case "Danger! Danger!" => true case _ => false }