Package akka.testkit
Class JavaTestKit
- java.lang.Object
-
- akka.testkit.JavaTestKit
-
@Deprecated public class JavaTestKit extends java.lang.Object
Deprecated.UseTestKit
instead, since 2.5.0Java API: Test kit for testing actors. Inheriting from this class enables reception of replies from actors, which are queued by an internal actor and can be examined using theexpectMsg...
methods. Assertions and bounds concerning timing are available in the form ofWithin
blocks.Beware of two points:
- the ActorSystem passed into the constructor needs to be shutdown, otherwise thread pools
and memory will be leaked - this trait is not thread-safe (only one actor with one queue,
one stack of
Within
blocks); take care not to run tests within a single test class instance in parallel. - It should be noted that for CI servers and the like all maximum Durations are scaled using
the
dilated
method, which uses the TestKitExtension.Settings.TestTimeFactor settable via akka.conf entry "akka.test.timefactor".
- the ActorSystem passed into the constructor needs to be shutdown, otherwise thread pools
and memory will be leaked - this trait is not thread-safe (only one actor with one queue,
one stack of
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
JavaTestKit.AwaitAssert
Deprecated.Await until the given assert does not throw an exception or the timeout expires, whichever comes first.class
JavaTestKit.AwaitCond
Deprecated.Await until the given condition evaluates totrue
or the timeout expires, whichever comes first.class
JavaTestKit.EventFilter<T>
Deprecated.Facilities for selectively filtering out expected events from logging so that you can keep your test run’s console output clean and do not miss real error messages.class
JavaTestKit.ExpectMsg<T>
Deprecated.Receive one message from the test actor and assert that the given matching function accepts it.class
JavaTestKit.IgnoreMsg
Deprecated.Ignore all messages in the test actor for which the given function returns true.class
JavaTestKit.ReceiveWhile<T>
Deprecated.Receive a series of messages until one does not match the givenmatch
function or the idle timeout is met (disabled by default) or the overall maximum duration is elapsed.class
JavaTestKit.Within
Deprecated.Execute code block while bounding its execution time betweenmin
andmax
.
-
Constructor Summary
Constructors Constructor Description JavaTestKit(ActorSystem system)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ActorRef
childActorOf(Props props)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef.ActorRef
childActorOf(Props props, SupervisorStrategy supervisorStrategy)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef.ActorRef
childActorOf(Props props, java.lang.String name)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef.ActorRef
childActorOf(Props props, java.lang.String name, SupervisorStrategy supervisorStrategy)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef.scala.concurrent.duration.Duration
dilated(scala.concurrent.duration.Duration d)
Deprecated.static scala.concurrent.duration.FiniteDuration
duration(java.lang.String s)
Deprecated.java.lang.Object[]
expectMsgAllOf(java.lang.Object... msgs)
Deprecated.Same asexpectMsgAllOf(remainingOrDefault(), obj...)
, but correctly treating the timeFactor.java.lang.Object[]
expectMsgAllOf(scala.concurrent.duration.FiniteDuration max, java.lang.Object... msgs)
Deprecated.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.<T> T
expectMsgAnyClassOf(java.lang.Class<? extends T>... classes)
Deprecated.Same asexpectMsgAnyClassOf(remainingOrDefault(), obj...)
, but correctly treating the timeFactor.java.lang.Object
expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max, java.lang.Class<?>... classes)
Deprecated.Receive one message from the test actor and assert that it conforms to one of the given classes.java.lang.Object
expectMsgAnyOf(java.lang.Object... msgs)
Deprecated.Same asexpectMsgAnyOf(remainingOrDefault(), obj...)
, but correctly treating the timeFactor.java.lang.Object
expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max, java.lang.Object... msgs)
Deprecated.Receive one message from the test actor and assert that it equals one of the given objects.<T> T
expectMsgClass(java.lang.Class<T> clazz)
Deprecated.Same asexpectMsgClass(remainingOrDefault(), clazz)
, but correctly treating the timeFactor.<T> T
expectMsgClass(scala.concurrent.duration.FiniteDuration max, java.lang.Class<T> clazz)
Deprecated.Receive one message from the test actor and assert that it conforms to the given class.<T> T
expectMsgEquals(scala.concurrent.duration.FiniteDuration max, T msg)
Deprecated.Receive one message from the test actor and assert that it equals the given object.<T> T
expectMsgEquals(T msg)
Deprecated.Same asexpectMsgEquals(remainingOrDefault(), obj)
, but correctly treating the timeFactor.void
expectNoMsg()
Deprecated.Same asexpectNoMsg(remainingOrDefault())
, but correctly treating the timeFactor.void
expectNoMsg(scala.concurrent.duration.FiniteDuration max)
Deprecated.Assert that no message is received for the specified time.Terminated
expectTerminated(ActorRef target)
Deprecated.Same asexpectTerminated(remainingOrDefault(), target)
, but correctly treating the timeFactor.Terminated
expectTerminated(scala.concurrent.duration.Duration max, ActorRef target)
Deprecated.Assert that the given ActorRef is Terminated within the specified time.void
forward(ActorRef actor)
Deprecated.ActorRef
getLastSender()
Deprecated.ActorRef
getRef()
Deprecated.Shorthand to get the testActor.scala.concurrent.duration.FiniteDuration
getRemainingTime()
Deprecated.scala.concurrent.duration.FiniteDuration
getRemainingTimeOr(scala.concurrent.duration.FiniteDuration def)
Deprecated.ActorSystem
getSystem()
Deprecated.ActorRef
getTestActor()
Deprecated.ActorRef of the test actor.void
ignoreNoMsg()
Deprecated.Stop ignoring messages in the test actor.boolean
msgAvailable()
Deprecated.Query queue status.java.lang.Object[]
receiveN(int n)
Deprecated.Same asreceiveN(n, remaining())
, but correctly treating the timeFactor.java.lang.Object[]
receiveN(int n, scala.concurrent.duration.FiniteDuration max)
Deprecated.Receive N messages in a row before the given deadline.java.lang.Object
receiveOne(scala.concurrent.duration.Duration max)
Deprecated.Receive one message from the internal queue of the TestActor.scala.concurrent.duration.FiniteDuration
remaining()
Deprecated.Obtain time remaining for execution of the innermost enclosingWithin
block or missing that it returns the properly dilated default for this case from settings (key "akka.test.single-expect-default").scala.concurrent.duration.FiniteDuration
remainingOr(scala.concurrent.duration.FiniteDuration duration)
Deprecated.Obtain time remaining for execution of the innermost enclosingWithin
block or missing that it returns the given duration.scala.concurrent.duration.FiniteDuration
remainingOrDefault()
Deprecated.Obtain time remaining for execution of the innermost enclosingWithin
block or missing that it returns the properly dilated default for this case from settings (key "akka.test.single-expect-default").void
reply(java.lang.Object msg)
Deprecated.void
send(ActorRef actor, java.lang.Object msg)
Deprecated.void
setAutoPilot(TestActor.AutoPilot pilot)
Deprecated.Install an AutoPilot to drive the testActor: the AutoPilot will be run for each received message and can be used to send or forward messages, etc.void
shutdown(ActorSystem actorSystem)
Deprecated.void
shutdown(ActorSystem actorSystem, java.lang.Boolean verifySystemShutdown)
Deprecated.void
shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration)
Deprecated.void
shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, java.lang.Boolean verifySystemShutdown)
Deprecated.Shut down an actor system and wait for termination.static void
shutdownActorSystem(ActorSystem actorSystem)
Deprecated.static void
shutdownActorSystem(ActorSystem actorSystem, java.lang.Boolean verifySystemShutdown)
Deprecated.static void
shutdownActorSystem(ActorSystem actorSystem, scala.concurrent.duration.Duration duration)
Deprecated.static void
shutdownActorSystem(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, java.lang.Boolean verifySystemShutdown)
Deprecated.Shut down an actor system and wait for termination.ActorRef
unwatch(ActorRef ref)
Deprecated.Have the testActor stop watching someone (i.e.ActorRef
watch(ActorRef ref)
Deprecated.Have the testActor watch someone (i.e.
-
-
-
Constructor Detail
-
JavaTestKit
public JavaTestKit(ActorSystem system)
Deprecated.
-
-
Method Detail
-
shutdownActorSystem
public static void shutdownActorSystem(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, java.lang.Boolean verifySystemShutdown)
Deprecated.Shut down an actor system and wait for termination. On failure debug output will be logged about the remaining actors in the system.If verifySystemShutdown is true, then an exception will be thrown on failure.
-
shutdownActorSystem
public static void shutdownActorSystem(ActorSystem actorSystem)
Deprecated.
-
shutdownActorSystem
public static void shutdownActorSystem(ActorSystem actorSystem, scala.concurrent.duration.Duration duration)
Deprecated.
-
shutdownActorSystem
public static void shutdownActorSystem(ActorSystem actorSystem, java.lang.Boolean verifySystemShutdown)
Deprecated.
-
getTestActor
public ActorRef getTestActor()
Deprecated.ActorRef of the test actor. Access is provided to enable e.g. registration as message target.
-
getRef
public ActorRef getRef()
Deprecated.Shorthand to get the testActor.
-
getSystem
public ActorSystem getSystem()
Deprecated.
-
duration
public static scala.concurrent.duration.FiniteDuration duration(java.lang.String s)
Deprecated.
-
dilated
public scala.concurrent.duration.Duration dilated(scala.concurrent.duration.Duration d)
Deprecated.
-
msgAvailable
public boolean msgAvailable()
Deprecated.Query queue status.
-
getLastSender
public ActorRef getLastSender()
Deprecated.
-
send
public void send(ActorRef actor, java.lang.Object msg)
Deprecated.
-
forward
public void forward(ActorRef actor)
Deprecated.
-
reply
public void reply(java.lang.Object msg)
Deprecated.
-
getRemainingTime
public scala.concurrent.duration.FiniteDuration getRemainingTime()
Deprecated.
-
getRemainingTimeOr
public scala.concurrent.duration.FiniteDuration getRemainingTimeOr(scala.concurrent.duration.FiniteDuration def)
Deprecated.
-
watch
public ActorRef watch(ActorRef ref)
Deprecated.Have the testActor watch someone (i.e.getContext().getWatch(...)
).
-
unwatch
public ActorRef unwatch(ActorRef ref)
Deprecated.Have the testActor stop watching someone (i.e.getContext.unwatch(...)
).
-
ignoreNoMsg
public void ignoreNoMsg()
Deprecated.Stop ignoring messages in the test actor.
-
setAutoPilot
public void setAutoPilot(TestActor.AutoPilot pilot)
Deprecated.Install an AutoPilot to drive the testActor: the AutoPilot will be run for each received message and can be used to send or forward messages, etc. Each invocation must return the AutoPilot for the next round.
-
remaining
public scala.concurrent.duration.FiniteDuration remaining()
Deprecated.Obtain time remaining for execution of the innermost enclosingWithin
block or missing that it returns the properly dilated default for this case from settings (key "akka.test.single-expect-default").
-
remainingOr
public scala.concurrent.duration.FiniteDuration remainingOr(scala.concurrent.duration.FiniteDuration duration)
Deprecated.Obtain time remaining for execution of the innermost enclosingWithin
block or missing that it returns the given duration.
-
remainingOrDefault
public scala.concurrent.duration.FiniteDuration remainingOrDefault()
Deprecated.Obtain time remaining for execution of the innermost enclosingWithin
block or missing that it returns the properly dilated default for this case from settings (key "akka.test.single-expect-default").
-
expectMsgEquals
public <T> T expectMsgEquals(T msg)
Deprecated.Same asexpectMsgEquals(remainingOrDefault(), obj)
, but correctly treating the timeFactor.
-
expectMsgEquals
public <T> T expectMsgEquals(scala.concurrent.duration.FiniteDuration max, T msg)
Deprecated.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.- Returns:
- the received object
-
expectMsgClass
public <T> T expectMsgClass(java.lang.Class<T> clazz)
Deprecated.Same asexpectMsgClass(remainingOrDefault(), clazz)
, but correctly treating the timeFactor.
-
expectMsgClass
public <T> T expectMsgClass(scala.concurrent.duration.FiniteDuration max, java.lang.Class<T> clazz)
Deprecated.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.- Returns:
- the received object
-
expectMsgAnyOf
public java.lang.Object expectMsgAnyOf(java.lang.Object... msgs)
Deprecated.Same asexpectMsgAnyOf(remainingOrDefault(), obj...)
, but correctly treating the timeFactor.
-
expectMsgAnyOf
public java.lang.Object expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max, java.lang.Object... msgs)
Deprecated.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.- Returns:
- the received object
-
expectMsgAllOf
public java.lang.Object[] expectMsgAllOf(java.lang.Object... msgs)
Deprecated.Same asexpectMsgAllOf(remainingOrDefault(), obj...)
, but correctly treating the timeFactor.
-
expectMsgAllOf
public java.lang.Object[] expectMsgAllOf(scala.concurrent.duration.FiniteDuration max, java.lang.Object... msgs)
Deprecated.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.
-
expectMsgAnyClassOf
public <T> T expectMsgAnyClassOf(java.lang.Class<? extends T>... classes)
Deprecated.Same asexpectMsgAnyClassOf(remainingOrDefault(), obj...)
, but correctly treating the timeFactor.
-
expectMsgAnyClassOf
public java.lang.Object expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max, java.lang.Class<?>... classes)
Deprecated.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.- Returns:
- the received object
-
expectNoMsg
public void expectNoMsg()
Deprecated.Same asexpectNoMsg(remainingOrDefault())
, but correctly treating the timeFactor.
-
expectNoMsg
public void expectNoMsg(scala.concurrent.duration.FiniteDuration max)
Deprecated.Assert that no message is received for the specified time.
-
expectTerminated
public Terminated expectTerminated(scala.concurrent.duration.Duration max, ActorRef target)
Deprecated.Assert that the given ActorRef is Terminated within the specified time. Don't forget to 'watch' it first!
-
expectTerminated
public Terminated expectTerminated(ActorRef target)
Deprecated.Same asexpectTerminated(remainingOrDefault(), target)
, but correctly treating the timeFactor. Don't forget to 'watch' it first!
-
receiveN
public java.lang.Object[] receiveN(int n)
Deprecated.Same asreceiveN(n, remaining())
, but correctly treating the timeFactor.
-
receiveN
public java.lang.Object[] receiveN(int n, scala.concurrent.duration.FiniteDuration max)
Deprecated.Receive N messages in a row before the given deadline.
-
receiveOne
public java.lang.Object receiveOne(scala.concurrent.duration.Duration max)
Deprecated.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!
-
shutdown
public void shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, java.lang.Boolean verifySystemShutdown)
Deprecated.Shut down an actor system and wait for termination. On failure debug output will be logged about the remaining actors in the system.If verifySystemShutdown is true, then an exception will be thrown on failure.
-
shutdown
public void shutdown(ActorSystem actorSystem)
Deprecated.
-
shutdown
public void shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration)
Deprecated.
-
shutdown
public void shutdown(ActorSystem actorSystem, java.lang.Boolean verifySystemShutdown)
Deprecated.
-
childActorOf
public ActorRef childActorOf(Props props, java.lang.String name, SupervisorStrategy supervisorStrategy)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef.- Parameters:
props
- Props to create the child actorname
- Actor name for the child actorsupervisorStrategy
- Strategy should decide what to do with failures in the actor.
-
childActorOf
public ActorRef childActorOf(Props props, SupervisorStrategy supervisorStrategy)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef. The actor will have an auto-generated name.- Parameters:
props
- Props to create the child actorsupervisorStrategy
- Strategy should decide what to do with failures in the actor.
-
childActorOf
public ActorRef childActorOf(Props props, java.lang.String name)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef. The actor will be supervised usingSupervisorStrategy.stoppingStrategy
.- Parameters:
props
- Props to create the child actorname
- Actor name for the child actor
-
childActorOf
public ActorRef childActorOf(Props props)
Deprecated.Spawns an actor as a child of this test actor, and returns the child's ActorRef. The actor will have an auto-generated name and will be supervised usingSupervisorStrategy.stoppingStrategy
.- Parameters:
props
- Props to create the child actor
-
-