Class TestKitJunitResource

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public final class TestKitJunitResource
    extends org.junit.rules.ExternalResource
    A Junit external resource for the ActorTestKit, making it possible to have Junit manage the lifecycle of the testkit. The testkit will be automatically shut down when the test completes or fails.

    Note that Junit is not provided as a transitive dependency of the testkit module but must be added explicitly to your project to use this.

    Example:

    
     public class MyActorTest {
       @ClassRule
       public static final TestKitResource testKit = new TestKitResource();
    
       @Test
       public void testBlah() throws Exception {
               // spawn actors etc using the testKit
               ActorRef<Message> ref = testKit.spawn(behavior);
       }
     }
     
    • Constructor Detail

      • TestKitJunitResource

        public TestKitJunitResource​(ActorTestKit _kit)
      • TestKitJunitResource

        public TestKitJunitResource()
      • TestKitJunitResource

        public TestKitJunitResource​(java.lang.String customConfig)
        Use a custom config for the actor system.
        Parameters:
        customConfig - (undocumented)
      • TestKitJunitResource

        public TestKitJunitResource​(com.typesafe.config.Config customConfig)
        Use a custom config for the actor system.
        Parameters:
        customConfig - (undocumented)
      • TestKitJunitResource

        public TestKitJunitResource​(com.typesafe.config.Config customConfig,
                                    TestKitSettings settings)
        Use a custom config for the actor system, and a custom TestKitSettings.
        Parameters:
        customConfig - (undocumented)
        settings - (undocumented)
    • Method Detail

      • after

        public void after()
        Overrides:
        after in class org.junit.rules.ExternalResource
      • createTestProbe

        public <M> TestProbe<M> createTestProbe()
        See corresponding method on ActorTestKit
        Returns:
        (undocumented)
      • createTestProbe

        public <M> TestProbe<M> createTestProbe​(java.lang.Class<M> clazz)
        See corresponding method on ActorTestKit
        Parameters:
        clazz - (undocumented)
        Returns:
        (undocumented)
      • createTestProbe

        public <M> TestProbe<M> createTestProbe​(java.lang.String name,
                                                java.lang.Class<M> clazz)
        See corresponding method on ActorTestKit
        Parameters:
        name - (undocumented)
        clazz - (undocumented)
        Returns:
        (undocumented)
      • createTestProbe

        public <M> TestProbe<M> createTestProbe​(java.lang.String name)
        See corresponding method on ActorTestKit
        Parameters:
        name - (undocumented)
        Returns:
        (undocumented)
      • scheduler

        public Scheduler scheduler()
        See corresponding method on ActorTestKit
        Returns:
        (undocumented)
      • spawn

        public <T> ActorRef<T> spawn​(Behavior<T> behavior)
        See corresponding method on ActorTestKit
        Parameters:
        behavior - (undocumented)
        Returns:
        (undocumented)
      • spawn

        public <T> ActorRef<T> spawn​(Behavior<T> behavior,
                                     java.lang.String name)
        See corresponding method on ActorTestKit
        Parameters:
        behavior - (undocumented)
        name - (undocumented)
        Returns:
        (undocumented)
      • spawn

        public <T> ActorRef<T> spawn​(Behavior<T> behavior,
                                     Props props)
        See corresponding method on ActorTestKit
        Parameters:
        behavior - (undocumented)
        props - (undocumented)
        Returns:
        (undocumented)
      • spawn

        public <T> ActorRef<T> spawn​(Behavior<T> behavior,
                                     java.lang.String name,
                                     Props props)
        See corresponding method on ActorTestKit
        Parameters:
        behavior - (undocumented)
        name - (undocumented)
        props - (undocumented)
        Returns:
        (undocumented)
      • system

        public ActorSystem<java.lang.Void> system()
        See corresponding method on ActorTestKit
        Returns:
        (undocumented)
      • timeout

        public Timeout timeout()
        See corresponding method on ActorTestKit
        Returns:
        (undocumented)