Class 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 Detail

      • ActorTestKit

        public ActorTestKit​(java.lang.String name,
                            com.typesafe.config.Config config,
                            scala.Option<TestKitSettings> settings)
    • Method Detail

      • 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 the ActorSystem and the testkit with shutdownTestKit().

        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 the ActorSystem and the testkit with shutdownTestKit().

        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 custom TestKitSettings

        It will create an ActorSystem with this name, e.g. threads will include the name. When the test has completed you should terminate the ActorSystem and the testkit with shutdownTestKit().

        Parameters:
        name - (undocumented)
        customConfig - (undocumented)
        settings - (undocumented)
        Returns:
        (undocumented)
      • shutdown

        public static void shutdown​(ActorSystem<?> system)
        Shutdown the given ActorSystem and block until it shuts down, if more time than TestKitSettings.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 given ActorSystem and block until it shuts down or the duration hits. If the timeout hits verifySystemShutdown 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()
      • system

        public ActorSystem<scala.runtime.Nothing$> system()
      • 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 this ActorTestKit. 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)
      • systemActor

        public <T> ActorRef<T> systemActor​(Behavior<T> behavior,
                                           java.lang.String name)