remove deprecated code from testkit (#1981)

* remove deprecated code from testkit

compile issues

* Update StreamTestKit.scala

* mima

* Update remove-deprecated-methods.excludes
This commit is contained in:
PJ Fanning 2025-07-31 12:42:38 +01:00 committed by GitHub
parent 1c1ca52ae4
commit c54e0ef89c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 50 additions and 383 deletions

View file

@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Remove deprecated methods
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.stream.testkit.TestPublisher#ManualProbe.expectNoMsg")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.stream.testkit.TestSubscriber#ManualProbe.expectNoMsg")

View file

@ -175,26 +175,6 @@ object TestPublisher {
self
}
/**
* Expect no messages.
* NOTE! Timeout value is automatically multiplied by timeFactor.
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.5")
def expectNoMsg(): Self = executeAfterSubscription {
probe.expectNoMsg()
self
}
/**
* Expect no messages for a given duration.
* NOTE! Timeout value is automatically multiplied by timeFactor.
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.5")
def expectNoMsg(max: FiniteDuration): Self = executeAfterSubscription {
probe.expectNoMsg(max)
self
}
/**
* Expect no messages.
* Waits for the default period configured as `pekko.actor.testkit.expect-no-message-default`.
@ -786,30 +766,6 @@ object TestSubscriber {
self
}
/**
* Fluent DSL
*
* Same as `expectNoMsg(remaining)`, but correctly treating the timeFactor.
* NOTE! Timeout value is automatically multiplied by timeFactor.
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.5")
def expectNoMsg(): Self = {
probe.expectNoMsg()
self
}
/**
* Fluent DSL
*
* Assert that no message is received for the specified time.
* NOTE! Timeout value is automatically multiplied by timeFactor.
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.5")
def expectNoMsg(remaining: FiniteDuration): Self = {
probe.expectNoMsg(remaining)
self
}
/**
* Fluent DSL
*

View file

@ -18,3 +18,27 @@
# Remove deprecated methods
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.ExplicitlyTriggeredScheduler.schedule")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.TestFSMRef.setTimer*")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.TestKit.expectNoMsg")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.TestKitBase.expectNoMsg")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.awaitAssert")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.awaitCond")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectMsg")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectMsgClass")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectMsgAllOf")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectMsgAnyOf")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectMsgAnyClassOf")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectMsgEquals")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectMsgPF")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectNoMsg")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectNoMessage")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.expectTerminated")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.dilated")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.fishForMessage")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.fishForSpecificMessage")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.receiveN")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.receiveOne")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.receiveWhile")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.remaining")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.remainingOr")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.remainingOrDefault")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.testkit.javadsl.TestKit.within")

View file

@ -718,23 +718,6 @@ trait TestKitBase {
recv.asInstanceOf[immutable.Seq[T]]
}
/**
* Assert that no message is received. Waits for the default period configured as
* `pekko.test.expect-no-message-default`.
* That timeout is scaled using the configuration entry "pekko.test.timefactor".
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.5")
def expectNoMsg(): Unit = expectNoMessage()
/**
* Assert that no message is received for the specified time.
* NOTE! Supplied value is always dilated.
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.5")
def expectNoMsg(max: FiniteDuration): Unit = {
expectNoMsg_internal(max.dilated)
}
/**
* Assert that no message is received for the specified time.
* Supplied value is not dilated.

View file

@ -19,8 +19,6 @@ import java.util.function.{ Function => JFunction, Supplier }
import scala.annotation.varargs
import scala.concurrent.duration._
import scala.annotation.nowarn
import org.apache.pekko
import pekko.actor._
import pekko.annotation.InternalApi
@ -76,12 +74,6 @@ class TestKit(system: ActorSystem) {
}
}
/**
* Scale timeouts (durations) during tests with the configured
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def dilated(d: FiniteDuration): FiniteDuration = d.dilated(getSystem)
/**
* Java timeouts (durations) during tests with the configured
*/
@ -147,14 +139,6 @@ class TestKit(system: ActorSystem) {
*/
def setAutoPilot(pilot: TestActor.AutoPilot): Unit = tp.setAutoPilot(pilot)
/**
* Obtain time remaining for execution of the innermost enclosing `within`
* block or throw an [[java.lang.AssertionError]] if no `within` block surrounds this
* call.
*/
@deprecated("Use getRemaining which returns java.time.Duration instead.", since = "Akka 2.5.12")
def remaining: FiniteDuration = tp.remaining
/**
* Obtain time remaining for execution of the innermost enclosing `within`
* block or throw an [[java.lang.AssertionError]] if no `within` block surrounds this
@ -162,27 +146,12 @@ class TestKit(system: ActorSystem) {
*/
def getRemaining: java.time.Duration = tp.remaining.asJava
/**
* Obtain time remaining for execution of the innermost enclosing `within`
* block or missing that it returns the given duration.
*/
@deprecated("Use getRemainingOr which returns java.time.Duration instead.", since = "Akka 2.5.12")
def remainingOr(fd: FiniteDuration): FiniteDuration = tp.remainingOr(fd)
/**
* Obtain time remaining for execution of the innermost enclosing `within`
* block or missing that it returns the given duration.
*/
def getRemainingOr(duration: java.time.Duration): java.time.Duration = tp.remainingOr(duration.asScala).asJava
/**
* Obtain time remaining for execution of the innermost enclosing `within`
* block or missing that it returns the properly dilated default for this
* case from settings (key "pekko.test.single-expect-default").
*/
@deprecated("Use getRemainingOrDefault which returns java.time.Duration instead.", since = "Akka 2.5.12")
def remainingOrDefault: FiniteDuration = tp.remainingOrDefault
/**
* Obtain time remaining for execution of the innermost enclosing `within`
* block or missing that it returns the properly dilated default for this
@ -190,27 +159,6 @@ class TestKit(system: ActorSystem) {
*/
def getRemainingOrDefault: java.time.Duration = tp.remainingOrDefault.asJava
/**
* Execute code block while bounding its execution time between `min` and
* `max`. `within` blocks may be nested. All methods in this trait which
* take maximum wait times are available in a version which implicitly uses
* the remaining time governed by the innermost enclosing `within` block.
*
* Note that the timeout is scaled using Duration.dilated, which uses the
* configuration entry "pekko.test.timefactor", while the min Duration is not.
*
* {{{
*
* within(duration("50 millis"), () -> {
* test.tell("ping");
* return expectMsgClass(String.class);
* });
*
* }}}
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def within[T](min: FiniteDuration, max: FiniteDuration, f: Supplier[T]): T = tp.within(min, max)(f.get)
/**
* Execute code block while bounding its execution time between `min` and
* `max`. `within` blocks may be nested. All methods in this trait which
@ -232,27 +180,6 @@ class TestKit(system: ActorSystem) {
def within[T](min: java.time.Duration, max: java.time.Duration, f: Supplier[T]): T =
tp.within(min.asScala, max.asScala)(f.get)
/**
* Execute code block while bounding its execution time between `min` and
* `max`. `within` blocks may be nested. All methods in this trait which
* take maximum wait times are available in a version which implicitly uses
* the remaining time governed by the innermost enclosing `within` block.
*
* Note that the timeout is scaled using Duration.dilated, which uses the
* configuration entry "pekko.test.timefactor", while the min Duration is not.
*
* {{{
*
* within(duration("50 millis"), () -> {
* test.tell("ping");
* return expectMsgClass(String.class);
* });
*
* }}}
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def within[T](max: FiniteDuration, f: Supplier[T]): T = tp.within(max)(f.get)
/**
* Execute code block while bounding its execution time between `min` and
* `max`. `within` blocks may be nested. All methods in this trait which
@ -285,19 +212,6 @@ class TestKit(system: ActorSystem) {
*/
def awaitCond(p: Supplier[Boolean]): Unit = tp.awaitCond(p.get)
/**
* Await until the given condition evaluates to `true` or the timeout
* expires, whichever comes first.
*
* If no timeout is given, take it from the innermost enclosing `within`
* block.
*
* Note that the timeout is scaled using Duration.dilated,
* which uses the configuration entry "pekko.test.timefactor".
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def awaitCond(max: Duration, p: Supplier[Boolean]): Unit = tp.awaitCond(p.get, max)
/**
* Await until the given condition evaluates to `true` or the timeout
* expires, whichever comes first.
@ -310,20 +224,6 @@ class TestKit(system: ActorSystem) {
*/
def awaitCond(max: java.time.Duration, p: Supplier[Boolean]): Unit = tp.awaitCond(p.get, max.asScala)
/**
* Await until the given condition evaluates to `true` or the timeout
* expires, whichever comes first.
*
* If no timeout is given, take it from the innermost enclosing `within`
* block.
*
* Note that the timeout is scaled using Duration.dilated,
* which uses the configuration entry "pekko.test.timefactor".
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def awaitCond(max: Duration, interval: Duration, p: Supplier[Boolean]): Unit =
tp.awaitCond(p.get, max, interval)
/**
* Await until the given condition evaluates to `true` or the timeout
* expires, whichever comes first.
@ -337,20 +237,6 @@ class TestKit(system: ActorSystem) {
def awaitCond(max: java.time.Duration, interval: java.time.Duration, p: Supplier[Boolean]): Unit =
tp.awaitCond(p.get, max.asScala, interval.asScala)
/**
* Await until the given condition evaluates to `true` or the timeout
* expires, whichever comes first.
*
* If no timeout is given, take it from the innermost enclosing `within`
* block.
*
* Note that the timeout is scaled using Duration.dilated,
* which uses the configuration entry "pekko.test.timefactor".
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def awaitCond(max: Duration, interval: Duration, message: String, p: Supplier[Boolean]): Unit =
tp.awaitCond(p.get, max, interval, message)
/**
* Await until the given condition evaluates to `true` or the timeout
* expires, whichever comes first.
@ -378,21 +264,6 @@ class TestKit(system: ActorSystem) {
*/
def awaitAssert[A](a: Supplier[A]): A = tp.awaitAssert(a.get)
/**
* Evaluate the given assert every `interval` until it does not throw an exception and return the
* result.
*
* If the `max` timeout expires the last exception is thrown.
*
* If no timeout is given, take it from the innermost enclosing `within`
* block.
*
* Note that the timeout is scaled using Duration.dilated,
* which uses the configuration entry "pekko.test.timefactor".
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.13")
def awaitAssert[A](max: Duration, a: Supplier[A]): A = tp.awaitAssert(a.get, max)
/**
* Evaluate the given assert every `interval` until it does not throw an exception and return the
* result.
@ -407,18 +278,6 @@ class TestKit(system: ActorSystem) {
*/
def awaitAssert[A](max: java.time.Duration, a: Supplier[A]): A = tp.awaitAssert(a.get, max.asScala)
/**
* Evaluate the given assert every `interval` until it does not throw an exception.
* If the `max` timeout expires the last exception is thrown.
*
* Note that the timeout is scaled using Duration.dilated,
* which uses the configuration entry "pekko.test.timefactor".
*
* @return an arbitrary value that would be returned from awaitAssert if successful, if not interested in such value you can return null.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.13")
def awaitAssert[A](max: Duration, interval: Duration, a: Supplier[A]): A = tp.awaitAssert(a.get, max, interval)
/**
* Evaluate the given assert every `interval` until it does not throw an exception.
* If the `max` timeout expires the last exception is thrown.
@ -436,16 +295,6 @@ class TestKit(system: ActorSystem) {
*/
def expectMsgEquals[T](obj: T): T = tp.expectMsg(obj)
/**
* Receive one message from the test actor and assert that it equals the given
* object. Wait time is bounded by the given duration, with an
* AssertionFailure being thrown in case of timeout.
*
* @return the received object
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectMsgEquals[T](max: FiniteDuration, obj: T): T = tp.expectMsg(max, obj)
/**
* Receive one message from the test actor and assert that it equals the given
* object. Wait time is bounded by the given duration, with an
@ -460,14 +309,6 @@ class TestKit(system: ActorSystem) {
*/
def expectMsg[T](obj: T): T = tp.expectMsg(obj)
/**
* Receive one message from the test actor and assert that it equals the
* given object. Wait time is bounded by the given duration, with an
* AssertionFailure being thrown in case of timeout.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectMsg[T](max: FiniteDuration, obj: T): T = tp.expectMsg(max, obj)
/**
* Receive one message from the test actor and assert that it equals the
* given object. Wait time is bounded by the given duration, with an
@ -475,14 +316,6 @@ class TestKit(system: ActorSystem) {
*/
def expectMsg[T](max: java.time.Duration, obj: T): T = tp.expectMsg(max.asScala, obj)
/**
* Receive one message from the test actor and assert that it equals the
* given object. Wait time is bounded by the given duration, with an
* AssertionFailure being thrown in case of timeout.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectMsg[T](max: FiniteDuration, obj: T, hint: String): T = tp.expectMsg(max, hint, obj)
/**
* Receive one message from the test actor and assert that it equals the
* given object. Wait time is bounded by the given duration, with an
@ -513,38 +346,18 @@ class TestKit(system: ActorSystem) {
* Use this variant to implement more complicated or conditional
* processing.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.6.0")
def expectMsgPF[T](max: Duration, hint: String, f: JFunction[Any, T]): T = {
tp.expectMsgPF(max, hint)(new CachingPartialFunction[Any, T] {
def expectMsgPF[T](max: java.time.Duration, hint: String, f: JFunction[Any, T]): T = {
tp.expectMsgPF(max.asScala, hint)(new CachingPartialFunction[Any, T] {
@throws(classOf[Exception])
override def `match`(x: Any): T = f.apply(x)
})
}
/**
* Receive one message from the test actor and assert that the given
* partial function accepts it. Wait time is bounded by the given duration,
* with an AssertionFailure being thrown in case of timeout.
*
* Use this variant to implement more complicated or conditional
* processing.
*/
@nowarn("msg=deprecated")
def expectMsgPF[T](max: java.time.Duration, hint: String, f: JFunction[Any, T]): T = expectMsgPF(max.asScala, hint, f)
/**
* Same as `expectMsgClass(remainingOrDefault, c)`, but correctly treating the timeFactor.
*/
def expectMsgClass[T](c: Class[T]): T = tp.expectMsgClass(c)
/**
* Receive one message from the test actor and assert that it conforms to
* the given class. Wait time is bounded by the given duration, with an
* AssertionFailure being thrown in case of timeout.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectMsgClass[T](max: FiniteDuration, c: Class[T]): T = tp.expectMsgClass(max, c)
/**
* Receive one message from the test actor and assert that it conforms to
* the given class. Wait time is bounded by the given duration, with an
@ -558,15 +371,6 @@ class TestKit(system: ActorSystem) {
@varargs
def expectMsgAnyOf[T](first: T, objs: T*): T = tp.expectMsgAnyOf((first +: objs): _*)
/**
* Receive one message from the test actor and assert that it equals one of
* the given objects. Wait time is bounded by the given duration, with an
* AssertionFailure being thrown in case of timeout.
*/
@varargs
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectMsgAnyOf[T](max: FiniteDuration, objs: T*): T = tp.expectMsgAnyOf(max, objs: _*)
/**
* Receive one message from the test actor and assert that it equals one of
* the given objects. Wait time is bounded by the given duration, with an
@ -581,17 +385,6 @@ class TestKit(system: ActorSystem) {
@varargs
def expectMsgAllOf[T](objs: T*): JList[T] = tp.expectMsgAllOf(objs: _*).asJava
/**
* Receive a number of messages from the test actor matching the given
* number of objects and assert that for each given object one is received
* which equals it and vice versa. This construct is useful when the order in
* which the objects are received is not fixed. Wait time is bounded by the
* given duration, with an AssertionFailure being thrown in case of timeout.
*/
@varargs
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectMsgAllOf[T](max: FiniteDuration, objs: T*): JList[T] = tp.expectMsgAllOf(max, objs: _*).asJava
/**
* Receive a number of messages from the test actor matching the given
* number of objects and assert that for each given object one is received
@ -609,16 +402,6 @@ class TestKit(system: ActorSystem) {
@varargs
def expectMsgAnyClassOf[T](objs: Class[_]*): T = tp.expectMsgAnyClassOf(objs: _*).asInstanceOf[T]
/**
* Receive one message from the test actor and assert that it conforms to
* one of the given classes. Wait time is bounded by the given duration,
* with an AssertionFailure being thrown in case of timeout.
*/
@varargs
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectMsgAnyClassOf[T](max: FiniteDuration, objs: Class[_]*): T =
tp.expectMsgAnyClassOf(max, objs: _*).asInstanceOf[T]
/**
* Receive one message from the test actor and assert that it conforms to
* one of the given classes. Wait time is bounded by the given duration,
@ -628,14 +411,6 @@ class TestKit(system: ActorSystem) {
def expectMsgAnyClassOf[T](max: java.time.Duration, objs: Class[_]*): T =
tp.expectMsgAnyClassOf(max.asScala, objs: _*).asInstanceOf[T]
/**
* Assert that no message is received. Waits for the default period configured as
* `pekko.actor.testkit.expect-no-message-default`.
* That timeout is scaled using the configuration entry "pekko.actor.testkit.typed.timefactor".
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.10")
def expectNoMsg(): Unit = tp.expectNoMessage()
/**
* Assert that no message is received. Waits for the default period configured as
* `pekko.actor.testkit.expect-no-message-default`.
@ -643,37 +418,12 @@ class TestKit(system: ActorSystem) {
*/
def expectNoMessage(): Unit = tp.expectNoMessage()
/**
* Assert that no message is received for the specified time.
*/
@deprecated(message = "Use expectNoMessage instead", since = "Akka 2.5.10")
def expectNoMsg(max: FiniteDuration): Unit = tp.expectNoMessage(max)
/**
* Assert that no message is received for the specified time.
* Supplied value is not dilated.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def expectNoMessage(max: FiniteDuration): Unit = tp.expectNoMessage(max)
/**
* Assert that no message is received for the specified time.
* Supplied value is not dilated.
*/
def expectNoMessage(max: java.time.Duration): Unit = tp.expectNoMessage(max.asScala)
/**
* Receive one message from the test actor and assert that it is the Terminated message of the given ActorRef.
* Before calling this method, you have to `watch` the target actor ref.
* Wait time is bounded by the given duration, with an AssertionFailure being thrown in case of timeout.
*
* @param max wait no more than max time, otherwise throw AssertionFailure
* @param target the actor ref expected to be Terminated
* @return the received Terminated message
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.6.0")
def expectTerminated(max: Duration, target: ActorRef): Terminated = tp.expectTerminated(target, max)
/**
* Receive one message from the test actor and assert that it is the Terminated message of the given ActorRef.
* Before calling this method, you have to `watch` the target actor ref.
@ -703,43 +453,22 @@ class TestKit(system: ActorSystem) {
* @return the last received message, i.e. the first one for which the
* partial function returned true
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.6.0")
def fishForMessage(max: Duration, hint: String, f: JFunction[Any, Boolean]): Any =
tp.fishForMessage(max, hint)(new CachingPartialFunction[Any, Boolean] {
def fishForMessage(max: java.time.Duration, hint: String, f: JFunction[Any, Boolean]): Any =
tp.fishForMessage(max.asScala, hint)(new CachingPartialFunction[Any, Boolean] {
@throws(classOf[Exception])
override def `match`(x: Any): Boolean = f.apply(x)
})
/**
* Hybrid of expectMsgPF and receiveWhile: receive messages while the
* partial function matches and returns false. Use it to ignore certain
* messages while waiting for a specific message.
*
* @return the last received message, i.e. the first one for which the
* partial function returned true
*/
@nowarn("msg=deprecated")
def fishForMessage(max: java.time.Duration, hint: String, f: JFunction[Any, Boolean]): Any =
fishForMessage(max.asScala, hint, f)
/**
* Same as `fishForMessage`, but gets a different partial function and returns properly typed message.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.6.0")
def fishForSpecificMessage[T](max: Duration, hint: String, f: JFunction[Any, T]): T = {
tp.fishForSpecificMessage(max, hint)(new CachingPartialFunction[Any, T] {
def fishForSpecificMessage[T](max: java.time.Duration, hint: String, f: JFunction[Any, T]): T = {
tp.fishForSpecificMessage(max.asScala, hint)(new CachingPartialFunction[Any, T] {
@throws(classOf[Exception])
override def `match`(x: Any): T = f.apply(x)
})
}
/**
* Same as `fishForMessage`, but gets a different partial function and returns properly typed message.
*/
@nowarn("msg=deprecated")
def fishForSpecificMessage[T](max: java.time.Duration, hint: String, f: JFunction[Any, T]): T =
fishForSpecificMessage(max.asScala, hint, f)
/**
* Same as `receiveN(n, remaining)` but correctly taking into account
* Duration.timeFactor.
@ -747,27 +476,11 @@ class TestKit(system: ActorSystem) {
def receiveN(n: Int): JList[AnyRef] =
tp.receiveN(n).asJava
/**
* Receive N messages in a row before the given deadline.
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.12")
def receiveN(n: Int, max: FiniteDuration): JList[AnyRef] =
tp.receiveN(n, max).asJava
/**
* Receive N messages in a row before the given deadline.
*/
def receiveN(n: Int, max: java.time.Duration): JList[AnyRef] = tp.receiveN(n, max.asScala).asJava
/**
* Receive one message from the internal queue of the TestActor. If the given
* duration is zero, the queue is polled (non-blocking).
*
* This method does NOT automatically scale its Duration parameter!
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.13")
def receiveOne(max: Duration): AnyRef = tp.receiveOne(max)
/**
* Receive one message from the internal queue of the TestActor. If the given
* duration is zero, the queue is polled (non-blocking).
@ -776,26 +489,6 @@ class TestKit(system: ActorSystem) {
*/
def receiveOne(max: java.time.Duration): AnyRef = tp.receiveOne(max.asScala)
/**
* Receive a series of messages until one does not match the given partial
* function or the idle timeout is met (disabled by default) or the overall
* maximum duration is elapsed or expected messages count is reached.
* Returns the sequence of messages.
*
* Note that it is not an error to hit the `max` duration in this case.
*
* One possible use of this method is for testing whether messages of
* certain characteristics are generated at a certain rate:
*/
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.13")
def receiveWhile[T](max: Duration, idle: Duration, messages: Int, f: JFunction[AnyRef, T]): JList[T] = {
tp.receiveWhile(max, idle, messages)(new CachingPartialFunction[AnyRef, T] {
@throws(classOf[Exception])
override def `match`(x: AnyRef): T = f.apply(x)
})
.asJava
}
/**
* Receive a series of messages until one does not match the given partial
* function or the idle timeout is met (disabled by default) or the overall
@ -819,15 +512,6 @@ class TestKit(system: ActorSystem) {
.asJava
}
@deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "Akka 2.5.13")
def receiveWhile[T](max: Duration, f: JFunction[AnyRef, T]): JList[T] = {
tp.receiveWhile(max = max)(new CachingPartialFunction[AnyRef, T] {
@throws(classOf[Exception])
override def `match`(x: AnyRef): T = f.apply(x)
})
.asJava
}
def receiveWhile[T](max: java.time.Duration, f: JFunction[AnyRef, T]): JList[T] = {
tp.receiveWhile(max = max.asScala)(new CachingPartialFunction[AnyRef, T] {
@throws(classOf[Exception])