Class ActorTestKit
- java.lang.Object
-
- akka.actor.testkit.typed.scaladsl.ActorTestKit
-
public final class ActorTestKit extends java.lang.Object
Spawn the given behavior. This is created as a child of the test kit guardian
-
-
Constructor Summary
Constructors Constructor Description ActorTestKit(java.lang.String name, com.typesafe.config.Config config, scala.Option<TestKitSettings> settings)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ActorTestKit
apply()
static ActorTestKit
apply(java.lang.String name)
Create a named testkit.static ActorTestKit
apply(java.lang.String name, com.typesafe.config.Config customConfig)
Create a named testkit, and use a custom config for the actor system.static ActorTestKit
apply(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
com.typesafe.config.Config
config()
<M> TestProbe<M>
createTestProbe()
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 systemjava.lang.String
name()
Scheduler
scheduler()
static void
shutdown(ActorSystem<?> system)
Shutdown the givenActorSystem
and block until it shuts down, if more time thanTestKitSettings.DefaultActorSystemShutdownTimeout
passes an exception is thrownstatic void
shutdown(ActorSystem<?> system, scala.concurrent.duration.Duration timeout, boolean throwIfShutdownFails)
Shutdown the givenActorSystem
and block until it shuts down or theduration
hits.static boolean
shutdown$default$3()
void
shutdownTestKit()
<T> ActorRef<T>
spawn(Behavior<T> behavior)
Spawn the given behavior.<T> ActorRef<T>
spawn(Behavior<T> behavior, Props props)
Spawn the given behavior.<T> ActorRef<T>
spawn(Behavior<T> behavior, java.lang.String name)
Spawn the given behavior.<T> ActorRef<T>
spawn(Behavior<T> behavior, java.lang.String name, Props props)
Spawn the given behavior.<T> void
stop(ActorRef<T> ref, scala.concurrent.duration.FiniteDuration max)
Stop the actor under test and wait until it terminates.<T> scala.concurrent.duration.FiniteDuration
stop$default$2()
ActorSystem<scala.runtime.Nothing$>
system()
<T> ActorRef<T>
systemActor(Behavior<T> behavior)
<T> ActorRef<T>
systemActor(Behavior<T> behavior, java.lang.String name)
TestKitSettings
testKitSettings()
Timeout
timeout()
-
-
-
Constructor Detail
-
ActorTestKit
public ActorTestKit(java.lang.String name, com.typesafe.config.Config config, scala.Option<TestKitSettings> settings)
-
-
Method Detail
-
apply
public static ActorTestKit apply()
-
apply
public static ActorTestKit apply(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)
-
apply
public static ActorTestKit apply(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)
-
apply
public static ActorTestKit apply(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)
Shutdown the givenActorSystem
and block until it shuts down, if more time thanTestKitSettings.DefaultActorSystemShutdownTimeout
passes an exception is thrown- Parameters:
system
- (undocumented)
-
shutdown
public static void shutdown(ActorSystem<?> system, scala.concurrent.duration.Duration timeout, boolean throwIfShutdownFails)
Shutdown the givenActorSystem
and block until it shuts down or theduration
hits. If the timeout hitsverifySystemShutdown
decides- Parameters:
system
- (undocumented)timeout
- (undocumented)throwIfShutdownFails
- (undocumented)
-
shutdown$default$3
public static boolean shutdown$default$3()
-
name
public java.lang.String name()
-
config
public com.typesafe.config.Config config()
-
testKitSettings
public TestKitSettings testKitSettings()
-
system
public ActorSystem<scala.runtime.Nothing$> system()
-
scheduler
public Scheduler scheduler()
-
timeout
public Timeout timeout()
-
shutdownTestKit
public void shutdownTestKit()
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior)
Spawn the given behavior. This is created as a child of the test kit guardian- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior, Props props)
Spawn the given behavior. This is created as a child of the test kit guardian- Parameters:
behavior
- (undocumented)props
- (undocumented)- Returns:
- (undocumented)
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior, java.lang.String name)
Spawn the given behavior. This is created as a child of the test kit guardian- Parameters:
behavior
- (undocumented)name
- (undocumented)- Returns:
- (undocumented)
-
spawn
public <T> ActorRef<T> spawn(Behavior<T> behavior, java.lang.String name, Props props)
Spawn the given behavior. This is created as a child of the test kit guardian- Parameters:
behavior
- (undocumented)name
- (undocumented)props
- (undocumented)- Returns:
- (undocumented)
-
stop
public <T> void stop(ActorRef<T> ref, scala.concurrent.duration.FiniteDuration max)
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)max
- (undocumented)
-
stop$default$2
public <T> scala.concurrent.duration.FiniteDuration stop$default$2()
-
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.String name)
Shortcut for creating a new named test probe for the testkit actor system- Parameters:
name
- (undocumented)- Returns:
- (undocumented)
-
-