Package akka.actor.testkit.typed.javadsl
Class ActorTestKit
- java.lang.Object
-
- akka.actor.testkit.typed.javadsl.ActorTestKit
-
public final class ActorTestKit extends java.lang.Object
The default timeout as specified with the config/TestKitSettings
-
-
Constructor Summary
Constructors Constructor Description ActorTestKit(ActorTestKit delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ActorTestKit
create()
static ActorTestKit
create(java.lang.String name)
Create a named testkit.static ActorTestKit
create(java.lang.String name, com.typesafe.config.Config customConfig)
Create a named testkit, and use a custom config for the actor system.static ActorTestKit
create(java.lang.String name, com.typesafe.config.Config customConfig, TestKitSettings settings)
Create a named testkit, and use a custom config for the actor system, and a customTestKitSettings
<M> TestProbe<M>
createTestProbe()
Shortcut for creating a new test probe for the testkit actor system<M> TestProbe<M>
createTestProbe(java.lang.Class<M> clazz)
Shortcut for creating a new test probe for the testkit actor system<M> TestProbe<M>
createTestProbe(java.lang.String name)
Shortcut for creating a new named test probe for the testkit actor system<M> TestProbe<M>
createTestProbe(java.lang.String name, java.lang.Class<M> clazz)
Shortcut for creating a new named test probe for the testkit actor systemScheduler
scheduler()
The scheduler of the testkit actor systemstatic void
shutdown(ActorSystem<?> system)
Shutdown the givenActorSystem
and block until it shuts down, if more time thansystem-shutdown-default
passes an exception is thrown (can be configured withthrow-on-shutdown-timeout
).static void
shutdown(ActorSystem<?> system, java.time.Duration duration)
Shutdown the givenActorSystem
and block until it shuts down, if more time thansystem-shutdown-default
passes an exception is thrown (can be configured withthrow-on-shutdown-timeout
).static void
shutdown(ActorSystem<?> system, java.time.Duration duration, boolean throwIfShutdownTimesOut)
Shutdown the given actor system and wait up toduration
for shutdown to complete.void
shutdownTestKit()
Terminate the actor system and the testkit<T> ActorRef<T>
spawn(Behavior<T> behavior)
Spawn a new auto-named actor under the testkit user guardian and return the ActorRef for the spawned actor<T> ActorRef<T>
spawn(Behavior<T> behavior, Props props)
Spawn a new auto-named actor under the testkit user guardian with the given props and return the ActorRef for the spawned actor<T> ActorRef<T>
spawn(Behavior<T> behavior, java.lang.String name)
Spawn a new named actor under the testkit user guardian and return the ActorRef for the spawned actor, note that spawning actors with the same name in multiple test cases will cause failures.<T> ActorRef<T>
spawn(Behavior<T> behavior, java.lang.String name, Props props)
Spawn a new named actor under the testkit user guardian with the given props and return the ActorRef for the spawned actor, note that spawning actors with the same name in multiple test cases will cause failures.<T> void
stop(ActorRef<T> ref)
Stop the actor under test and wait until it terminates.<T> void
stop(ActorRef<T> ref, java.time.Duration max)
Stop the actor under test and waitmax
until it terminates.ActorSystem<java.lang.Void>
system()
The actor system running for this testkit.TestKitSettings
testKitSettings()
Timeout
timeout()
-
-
-
Constructor Detail
-
ActorTestKit
public ActorTestKit(ActorTestKit delegate)
-
-
Method Detail
-
create
public static ActorTestKit create()
-
create
public static ActorTestKit create(java.lang.String name)
Create a named testkit.It will create an
ActorSystem
with this name, e.g. threads will include the name. When the test has completed you should terminate theActorSystem
and the testkit withshutdownTestKit()
.- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
create
public static ActorTestKit create(java.lang.String name, com.typesafe.config.Config customConfig)
Create a named testkit, and use a custom config for the actor system.It will create an
ActorSystem
with this name, e.g. threads will include the name. When the test has completed you should terminate theActorSystem
and the testkit withshutdownTestKit()
.- Parameters:
name
- (undocumented)customConfig
- (undocumented)- Returns:
- (undocumented)
-
create
public static ActorTestKit create(java.lang.String name, com.typesafe.config.Config customConfig, TestKitSettings settings)
Create a named testkit, and use a custom config for the actor system, and a customTestKitSettings
It will create an
ActorSystem
with this name, e.g. threads will include the name. When the test has completed you should terminate theActorSystem
and the testkit withshutdownTestKit()
.- Parameters:
name
- (undocumented)customConfig
- (undocumented)settings
- (undocumented)- Returns:
- (undocumented)
-
shutdown
public static void shutdown(ActorSystem<?> system, java.time.Duration duration, boolean throwIfShutdownTimesOut)
Shutdown the given actor system and wait up toduration
for shutdown to complete.- Parameters:
throwIfShutdownTimesOut
- Fail the test if the system fails to shut down, if false an error is printed to stdout when the system did not shutdown but no exception is thrown.system
- (undocumented)duration
- (undocumented)
-
shutdown
public static void shutdown(ActorSystem<?> system, java.time.Duration duration)
Shutdown the givenActorSystem
and block until it shuts down, if more time thansystem-shutdown-default
passes an exception is thrown (can be configured withthrow-on-shutdown-timeout
).- Parameters:
system
- (undocumented)duration
- (undocumented)
-
shutdown
public static void shutdown(ActorSystem<?> system)
Shutdown the givenActorSystem
and block until it shuts down, if more time thansystem-shutdown-default
passes an exception is thrown (can be configured withthrow-on-shutdown-timeout
).- Parameters:
system
- (undocumented)
-
timeout
public Timeout timeout()
-
system
public ActorSystem<java.lang.Void> system()
The actor system running for this testkit. Interaction with the user guardian is done through methods on the testkit which is why it is typed toVoid
.- Returns:
- (undocumented)
-
testKitSettings
public TestKitSettings testKitSettings()
-
scheduler
public Scheduler scheduler()
The scheduler of the testkit actor system- Returns:
- (undocumented)
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior)
Spawn a new auto-named actor under the testkit user guardian and return the ActorRef for the spawned actor- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior, java.lang.String name)
Spawn a new named actor under the testkit user guardian and return the ActorRef for the spawned actor, note that spawning actors with the same name in multiple test cases will cause failures.- Parameters:
behavior
- (undocumented)name
- (undocumented)- Returns:
- (undocumented)
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior, Props props)
Spawn a new auto-named actor under the testkit user guardian with the given props and return the ActorRef for the spawned actor- Parameters:
behavior
- (undocumented)props
- (undocumented)- Returns:
- (undocumented)
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior, java.lang.String name, Props props)
Spawn a new named actor under the testkit user guardian with the given props and return the ActorRef for the spawned actor, note that spawning actors with the same name in multiple test cases will cause failures.- Parameters:
behavior
- (undocumented)name
- (undocumented)props
- (undocumented)- Returns:
- (undocumented)
-
stop
public <T> void stop(ActorRef<T> ref)
Stop the actor under test and wait until it terminates. It can only be used for actors that were spawned by thisActorTestKit
. Other actors will not be stopped by this method.- Parameters:
ref
- (undocumented)
-
stop
public <T> void stop(ActorRef<T> ref, java.time.Duration max)
Stop the actor under test and waitmax
until it terminates. It can only be used for actors that were spawned by thisActorTestKit
. Other actors will not be stopped by this method.- Parameters:
ref
- (undocumented)max
- (undocumented)
-
createTestProbe
public <M> TestProbe<M> createTestProbe()
Shortcut for creating a new test probe for the testkit actor system- Returns:
- (undocumented)
-
createTestProbe
public <M> TestProbe<M> createTestProbe(java.lang.Class<M> clazz)
Shortcut for creating a new test probe for the testkit actor system- Parameters:
clazz
- (undocumented)- Returns:
- (undocumented)
-
createTestProbe
public <M> TestProbe<M> createTestProbe(java.lang.String name)
Shortcut for creating a new named test probe for the testkit actor system- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
createTestProbe
public <M> TestProbe<M> createTestProbe(java.lang.String name, java.lang.Class<M> clazz)
Shortcut for creating a new named test probe for the testkit actor system- Parameters:
name
- (undocumented)clazz
- (undocumented)- Returns:
- (undocumented)
-
shutdownTestKit
public void shutdownTestKit()
Terminate the actor system and the testkit
-
-