Package csw.testkit

Class FrameworkTestKit

java.lang.Object
csw.testkit.FrameworkTestKit

public final class FrameworkTestKit extends Object
FrameworkTestKit supports starting one or more services from csw.testkit.scaladsl.CSWService It also provides helpers to spawn components in standalone or container mode

Example:


   private val testKit = FrameworkTestKit()

   // this will start Event and Alarm Server (Note: Location Server will always be started as it is required by all other services)
   testKit.start(EventServer, AlarmServer)

   // spawn component in standalone mode
   testKit.spawnStandalone(ConfigFactory.load("standalone.conf"))

   // stopping services
   testKit.shutdown()

 
  • Constructor Details

    • FrameworkTestKit

      public FrameworkTestKit()
  • Method Details

    • apply

      public static FrameworkTestKit apply(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem, TestKitSettings testKitSettings)
      Scala API for creating FrameworkTestKit

      Parameters:
      actorSystem - actorSystem used for spawning components
      testKitSettings - custom testKitSettings
      Returns:
      handle to FrameworkTestKit which can be used to start and stop all services started
    • create

      public static FrameworkTestKit create()
      Java API for creating FrameworkTestKit

      Returns:
      handle to FrameworkTestKit which can be used to start and stop all services started
    • create

      public static FrameworkTestKit create(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem)
      Java API for creating FrameworkTestKit

      Parameters:
      actorSystem - actorSystem used for spawning components
      Returns:
      handle to FrameworkTestKit which can be used to start and stop all services started
    • create

      public static FrameworkTestKit create(TestKitSettings testKitSettings)
      Java API for creating FrameworkTestKit

      Parameters:
      testKitSettings - custom testKitSettings
      Returns:
      handle to FrameworkTestKit which can be used to start and stop all services started
    • start

      public void start(csw.testkit.scaladsl.CSWService... services)
      Before running tests, use this or [FrameworkTestKit#startAll] method to start required services

      This will always start location server as it is required by all other services along with provided services

      Parameters:
      services - (undocumented)
    • redisClient

      public io.lettuce.core.RedisClient redisClient()
    • locationTestKit

      public LocationTestKit locationTestKit()
    • configTestKit

      public ConfigTestKit configTestKit()
    • eventTestKit

      public EventTestKit eventTestKit()
    • alarmTestKit

      public AlarmTestKit alarmTestKit()
    • databaseTestKit

      public DatabaseTestKit databaseTestKit()
    • eventServiceFactory

      public EventServiceFactory eventServiceFactory()
    • actorSystem

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

      public scala.concurrent.ExecutionContext ec()
    • locationService

      public csw.location.api.scaladsl.LocationService locationService()
    • configClientService

      public csw.config.api.scaladsl.ConfigClientService configClientService()
    • eventService

      public csw.event.api.scaladsl.EventService eventService()
    • alarmServiceFactory

      public AlarmServiceFactory alarmServiceFactory()
    • timeout

      public akka.util.Timeout timeout()
    • startAll

      public void startAll()
      Before running tests, use this or [FrameworkTestKit#start] method to start required services

      This will start following services: [LocationServer, ConfigServer, EventServer, AlarmServer]

    • start

      public void start(scala.collection.immutable.Seq<csw.testkit.scaladsl.CSWService> services)
      Before running tests, use this or [FrameworkTestKit#startAll] method to start required services

      This will always start location server as it is required by all other services along with provided services

      Parameters:
      services - (undocumented)
    • spawnStandalone

      public akka.actor.typed.ActorRef<ComponentMessage> spawnStandalone(com.typesafe.config.Config config)
      Use this to start component in standalone mode

      Parameters:
      config - configuration of standalone component
      Returns:
      actorRef of spawned standalone component (supervisor)
    • spawnContainer

      public akka.actor.typed.ActorRef<ContainerMessage> spawnContainer(com.typesafe.config.Config config)
      Use this to start multiple components in container mode

      Parameters:
      config - configuration of container
      Returns:
      actorRef of spawned container
    • spawnHCD

      public akka.actor.typed.ActorRef<ComponentMessage> spawnHCD(Prefix prefix, scala.Function2<akka.actor.typed.scaladsl.ActorContext<TopLevelActorMessage>,CswContext,csw.framework.scaladsl.ComponentHandlers> behaviorFactory, LocationServiceUsage locationServiceUsage, scala.collection.immutable.Set<Connection> connections, scala.concurrent.duration.FiniteDuration initializeTimeout)
      Use this to start hcd in standalone mode

      Parameters:
      prefix - prefix of the hcd
      behaviorFactory - behavior factory for the hcd
      locationServiceUsage - location service usages of the hcd
      connections - connections to track for the hcd
      initializeTimeout - initialize timeout for the hcd
      Returns:
      actorRef of spawned hcd
    • spawnAssembly

      public akka.actor.typed.ActorRef<ComponentMessage> spawnAssembly(Prefix prefix, scala.Function2<akka.actor.typed.scaladsl.ActorContext<TopLevelActorMessage>,CswContext,csw.framework.scaladsl.ComponentHandlers> behaviorFactory, LocationServiceUsage locationServiceUsage, scala.collection.immutable.Set<Connection> connections, scala.concurrent.duration.FiniteDuration initializeTimeout)
      Use this to start assembly in standalone mode

      Parameters:
      prefix - prefix of the assembly
      behaviorFactory - behavior factory for the assembly
      locationServiceUsage - location service usages of the assembly
      connections - connections to track for the assembly
      initializeTimeout - initialize timeout for the assembly
      Returns:
      actorRef of spawned assembly
    • shutdown

      public void shutdown()
      Shutdown all testkits which are started.