From e5cdf9824c369859e6d5b90cef6762513d439e9b Mon Sep 17 00:00:00 2001 From: Sebastien Coquelin Date: Fri, 4 May 2018 23:06:58 -0400 Subject: [PATCH] Introduced new awaitAssert methods accepting java.time.Duration parameters --- .../scala/akka/testkit/javadsl/TestKit.scala | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/akka-testkit/src/main/scala/akka/testkit/javadsl/TestKit.scala b/akka-testkit/src/main/scala/akka/testkit/javadsl/TestKit.scala index 6ba53adb50..f2140682c3 100644 --- a/akka-testkit/src/main/scala/akka/testkit/javadsl/TestKit.scala +++ b/akka-testkit/src/main/scala/akka/testkit/javadsl/TestKit.scala @@ -388,9 +388,23 @@ class TestKit(system: ActorSystem) { * which uses the configuration entry "akka.test.timefactor". */ @Deprecated - @deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "2.5.12") + @deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "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. + * + * 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 "akka.test.timefactor". + */ + 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. @@ -400,8 +414,21 @@ class TestKit(system: ActorSystem) { * * @return an arbitrary value that would be returned from awaitAssert if successful, if not interested in such value you can return null. */ + @Deprecated + @deprecated("Use the overloaded one which accepts java.time.Duration instead.", since = "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. + * + * Note that the timeout is scaled using Duration.dilated, + * which uses the configuration entry "akka.test.timefactor". + * + * @return an arbitrary value that would be returned from awaitAssert if successful, if not interested in such value you can return null. + */ + def awaitAssert[A](max: java.time.Duration, interval: java.time.Duration, a: Supplier[A]): A = tp.awaitAssert(a.get, max.asScala, interval.asScala) + /** * Same as `expectMsg(remainingOrDefault, obj)`, but correctly treating the timeFactor. */