Class FrameworkTestKitJunitResource

java.lang.Object
org.junit.rules.ExternalResource
csw.testkit.javadsl.FrameworkTestKitJunitResource
All Implemented Interfaces:
org.junit.rules.TestRule

public final class FrameworkTestKitJunitResource extends org.junit.rules.ExternalResource
A Junit external resource for the FrameworkTestKit, 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.

Example:


 public class JFrameworkExampleTest {

  @ClassRule
   public static final FrameworkTestKitJunitResource testKit =
      new FrameworkTestKitJunitResource(JCSWService.EventServer, JCSWService.ConfigServer);

   @Test
   public void spawnContainer() {
      ActorRef<ContainerMessage> containerRef =
      testKit.spawnContainer(ConfigFactory.load("container.conf"))
   }

 }
 
  • Constructor Details

    • FrameworkTestKitJunitResource

      public FrameworkTestKitJunitResource(FrameworkTestKit frameworkTestKit, List<csw.testkit.scaladsl.CSWService> services)
    • FrameworkTestKitJunitResource

      public FrameworkTestKitJunitResource()
      Initialize testkit with default configuration

      By default only Location server gets started, if your tests requires other services [ex. Config, Event, Alarm etc.] along with location, then use other override which accepts sequence of csw.testkit.scaladsl.CSWService to create instance of testkit

    • FrameworkTestKitJunitResource

      public FrameworkTestKitJunitResource(List<csw.testkit.scaladsl.CSWService> services)
      Initialize testkit and start all the provided services.

      Parameters:
      services - (undocumented)
    • FrameworkTestKitJunitResource

      public FrameworkTestKitJunitResource(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem)
      Initialize testkit with provided actorSystem
  • Method Details

    • actorSystem

      public akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem()
    • after

      public void after()
      Shuts down the FrameworkTestKit
      Overrides:
      after in class org.junit.rules.ExternalResource
    • before

      public void before()
      Start FrameworkTestKit
      Overrides:
      before in class org.junit.rules.ExternalResource
    • frameworkTestKit

      public FrameworkTestKit frameworkTestKit()
    • jEventService

      public IEventService jEventService()
    • jLocationService

      public ILocationService jLocationService()
    • spawnContainer

      public akka.actor.typed.ActorRef<ContainerMessage> spawnContainer(com.typesafe.config.Config config)
      Delegate to framework testkit
    • spawnStandalone

      public akka.actor.typed.ActorRef<ComponentMessage> spawnStandalone(com.typesafe.config.Config config)
      Delegate to framework testkit