|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object akka.testkit.JavaTestKit
public class JavaTestKit
Java 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 the expectMsg...
methods. Assertions and
bounds concerning timing are available in the form of Within
blocks.
Beware of two points:
Within
blocks); take care not to run tests within a single test class instance in
parallel.dilated
method, which uses the
TestKitExtension.Settings.TestTimeFactor settable via akka.conf entry
"akka.test.timefactor".
Nested Class Summary | |
---|---|
class |
JavaTestKit.AwaitAssert
Await until the given assert does not throw an exception or the timeout expires, whichever comes first. |
class |
JavaTestKit.AwaitCond
Await until the given condition evaluates to true or the
timeout expires, whichever comes first. |
class |
JavaTestKit.EventFilter<T>
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>
Receive one message from the test actor and assert that the given matching function accepts it. |
class |
JavaTestKit.IgnoreMsg
Ignore all messages in the test actor for which the given function returns true. |
class |
JavaTestKit.ReceiveWhile<T>
Receive a series of messages until one does not match the given match function or the idle timeout is met (disabled by
default) or the overall maximum duration is elapsed. |
class |
JavaTestKit.Within
Execute code block while bounding its execution time between min and max . |
Constructor Summary | |
---|---|
JavaTestKit(ActorSystem system)
|
Method Summary | ||
---|---|---|
scala.concurrent.duration.Duration |
dilated(scala.concurrent.duration.Duration d)
|
|
static scala.concurrent.duration.FiniteDuration |
duration(java.lang.String s)
|
|
java.lang.Object[] |
expectMsgAllOf(scala.concurrent.duration.FiniteDuration max,
java.lang.Object... msgs)
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. |
|
java.lang.Object[] |
expectMsgAllOf(java.lang.Object... msgs)
Same as expectMsgAllOf(remaining(), obj...) , but correctly
treating the timeFactor. |
|
|
expectMsgAnyClassOf(java.lang.Class<? extends T>... classes)
Same as expectMsgAnyClassOf(remaining(), obj...) , but
correctly treating the timeFactor. |
|
java.lang.Object |
expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max,
java.lang.Class<?>... classes)
Receive one message from the test actor and assert that it conforms to one of the given classes. |
|
java.lang.Object |
expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max,
java.lang.Object... msgs)
Receive one message from the test actor and assert that it equals one of the given objects. |
|
java.lang.Object |
expectMsgAnyOf(java.lang.Object... msgs)
Same as expectMsgAnyOf(remaining(), obj...) , but correctly
treating the timeFactor. |
|
|
expectMsgClass(java.lang.Class<T> clazz)
Same as expectMsgClass(remaining(), clazz) , but correctly
treating the timeFactor. |
|
|
expectMsgClass(scala.concurrent.duration.FiniteDuration max,
java.lang.Class<T> clazz)
Receive one message from the test actor and assert that it conforms to the given class. |
|
|
expectMsgEquals(scala.concurrent.duration.FiniteDuration max,
T msg)
Receive one message from the test actor and assert that it equals the given object. |
|
|
expectMsgEquals(T msg)
Same as expectMsgEquals(remaining(), obj) , but correctly
treating the timeFactor. |
|
void |
expectNoMsg()
Same as expectNoMsg(remaining()) , but correctly treating the
timeFactor. |
|
void |
expectNoMsg(scala.concurrent.duration.FiniteDuration max)
Assert that no message is received for the specified time. |
|
Terminated |
expectTerminated(ActorRef target)
Same as expectTerminated(remaining(), target) ,
but correctly treating the timeFactor. |
|
Terminated |
expectTerminated(scala.concurrent.duration.Duration max,
ActorRef target)
Assert that the given ActorRef is Terminated within the specified time. |
|
void |
forward(ActorRef actor)
|
|
ActorRef |
getLastSender()
|
|
ActorRef |
getRef()
Shorthand to get the testActor. |
|
scala.concurrent.duration.FiniteDuration |
getRemainingTime()
|
|
scala.concurrent.duration.FiniteDuration |
getRemainingTimeOr(scala.concurrent.duration.FiniteDuration def)
|
|
ActorSystem |
getSystem()
|
|
ActorRef |
getTestActor()
ActorRef of the test actor. |
|
void |
ignoreNoMsg()
Stop ignoring messages in the test actor. |
|
boolean |
msgAvailable()
Query queue status. |
|
java.lang.Object[] |
receiveN(int n)
Same as receiveN(n, remaining()) , but correctly treating the
timeFactor. |
|
java.lang.Object[] |
receiveN(int n,
scala.concurrent.duration.FiniteDuration max)
Receive N messages in a row before the given deadline. |
|
java.lang.Object |
receiveOne(scala.concurrent.duration.Duration max)
Receive one message from the internal queue of the TestActor. |
|
scala.concurrent.duration.FiniteDuration |
remaining()
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
"akka.test.single-expect-default"). |
|
scala.concurrent.duration.FiniteDuration |
remainingOr(scala.concurrent.duration.FiniteDuration duration)
Obtain time remaining for execution of the innermost enclosing Within block or missing that it returns the given duration. |
|
void |
reply(java.lang.Object msg)
|
|
void |
send(ActorRef actor,
java.lang.Object msg)
|
|
void |
setAutoPilot(TestActor.AutoPilot pilot)
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)
|
|
void |
shutdown(ActorSystem actorSystem,
java.lang.Boolean verifySystemShutdown)
|
|
void |
shutdown(ActorSystem actorSystem,
scala.concurrent.duration.Duration duration)
|
|
void |
shutdown(ActorSystem actorSystem,
scala.concurrent.duration.Duration duration,
java.lang.Boolean verifySystemShutdown)
Shut down an actor system and wait for termination. |
|
static void |
shutdownActorSystem(ActorSystem actorSystem)
|
|
void |
shutdownActorSystem(ActorSystem actorSystem,
java.lang.Boolean verifySystemShutdown)
|
|
void |
shutdownActorSystem(ActorSystem actorSystem,
scala.concurrent.duration.Duration duration)
|
|
static void |
shutdownActorSystem(ActorSystem actorSystem,
scala.concurrent.duration.Duration duration,
java.lang.Boolean verifySystemShutdown)
Shut down an actor system and wait for termination. |
|
ActorRef |
unwatch(ActorRef ref)
Have the testActor stop watching someone (i.e. |
|
ActorRef |
watch(ActorRef ref)
Have the testActor watch someone (i.e. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JavaTestKit(ActorSystem system)
Method Detail |
---|
public static void shutdownActorSystem(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, java.lang.Boolean verifySystemShutdown)
If verifySystemShutdown is true, then an exception will be thrown on failure.
public static void shutdownActorSystem(ActorSystem actorSystem)
public void shutdownActorSystem(ActorSystem actorSystem, scala.concurrent.duration.Duration duration)
public void shutdownActorSystem(ActorSystem actorSystem, java.lang.Boolean verifySystemShutdown)
public ActorRef getTestActor()
public ActorRef getRef()
public ActorSystem getSystem()
public static scala.concurrent.duration.FiniteDuration duration(java.lang.String s)
public scala.concurrent.duration.Duration dilated(scala.concurrent.duration.Duration d)
public boolean msgAvailable()
public ActorRef getLastSender()
public void send(ActorRef actor, java.lang.Object msg)
public void forward(ActorRef actor)
public void reply(java.lang.Object msg)
public scala.concurrent.duration.FiniteDuration getRemainingTime()
public scala.concurrent.duration.FiniteDuration getRemainingTimeOr(scala.concurrent.duration.FiniteDuration def)
public ActorRef watch(ActorRef ref)
getContext().getWatch(...)
).
public ActorRef unwatch(ActorRef ref)
getContext.unwatch(...)
).
public void ignoreNoMsg()
public void setAutoPilot(TestActor.AutoPilot pilot)
public scala.concurrent.duration.FiniteDuration remaining()
Within
block or missing that it returns the properly dilated
default for this case from settings (key
"akka.test.single-expect-default").
public scala.concurrent.duration.FiniteDuration remainingOr(scala.concurrent.duration.FiniteDuration duration)
Within
block or missing that it returns the given duration.
public <T> T expectMsgEquals(T msg)
expectMsgEquals(remaining(), obj)
, but correctly
treating the timeFactor.
public <T> T expectMsgEquals(scala.concurrent.duration.FiniteDuration max, T msg)
public <T> T expectMsgClass(java.lang.Class<T> clazz)
expectMsgClass(remaining(), clazz)
, but correctly
treating the timeFactor.
public <T> T expectMsgClass(scala.concurrent.duration.FiniteDuration max, java.lang.Class<T> clazz)
public java.lang.Object expectMsgAnyOf(java.lang.Object... msgs)
expectMsgAnyOf(remaining(), obj...)
, but correctly
treating the timeFactor.
public java.lang.Object expectMsgAnyOf(scala.concurrent.duration.FiniteDuration max, java.lang.Object... msgs)
public java.lang.Object[] expectMsgAllOf(java.lang.Object... msgs)
expectMsgAllOf(remaining(), obj...)
, but correctly
treating the timeFactor.
public java.lang.Object[] expectMsgAllOf(scala.concurrent.duration.FiniteDuration max, java.lang.Object... msgs)
public <T> T expectMsgAnyClassOf(java.lang.Class<? extends T>... classes)
expectMsgAnyClassOf(remaining(), obj...)
, but
correctly treating the timeFactor.
public java.lang.Object expectMsgAnyClassOf(scala.concurrent.duration.FiniteDuration max, java.lang.Class<?>... classes)
public void expectNoMsg()
expectNoMsg(remaining())
, but correctly treating the
timeFactor.
public void expectNoMsg(scala.concurrent.duration.FiniteDuration max)
public Terminated expectTerminated(scala.concurrent.duration.Duration max, ActorRef target)
public Terminated expectTerminated(ActorRef target)
expectTerminated(remaining(), target)
,
but correctly treating the timeFactor.
Don't forget to 'watch' it first!
public java.lang.Object[] receiveN(int n)
receiveN(n, remaining())
, but correctly treating the
timeFactor.
public java.lang.Object[] receiveN(int n, scala.concurrent.duration.FiniteDuration max)
public java.lang.Object receiveOne(scala.concurrent.duration.Duration max)
This method does NOT automatically scale its Duration parameter!
public void shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration, java.lang.Boolean verifySystemShutdown)
If verifySystemShutdown is true, then an exception will be thrown on failure.
public void shutdown(ActorSystem actorSystem)
public void shutdown(ActorSystem actorSystem, scala.concurrent.duration.Duration duration)
public void shutdown(ActorSystem actorSystem, java.lang.Boolean verifySystemShutdown)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |