Package csw.testkit
Class FrameworkTestKit
java.lang.Object
csw.testkit.FrameworkTestKit
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionakka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command>
static FrameworkTestKit
apply
(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem, TestKitSettings testKitSettings) Scala API for creating FrameworkTestKitcsw.config.api.scaladsl.ConfigClientService
static FrameworkTestKit
create()
Java API for creating FrameworkTestKitstatic FrameworkTestKit
create
(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem) Java API for creating FrameworkTestKitstatic FrameworkTestKit
create
(TestKitSettings testKitSettings) Java API for creating FrameworkTestKitscala.concurrent.ExecutionContext
ec()
csw.event.api.scaladsl.EventService
csw.location.api.scaladsl.LocationService
io.lettuce.core.RedisClient
void
shutdown()
Shutdown all testkits which are started.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 modeakka.actor.typed.ActorRef<ContainerMessage>
spawnContainer
(com.typesafe.config.Config config) Use this to start multiple components in container modeakka.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 modeakka.actor.typed.ActorRef<ComponentMessage>
spawnStandalone
(com.typesafe.config.Config config) Use this to start component in standalone modevoid
start
(csw.testkit.scaladsl.CSWService... services) Before running tests, use this or [FrameworkTestKit#startAll] method to start required servicesvoid
start
(scala.collection.immutable.Seq<csw.testkit.scaladsl.CSWService> services) Before running tests, use this or [FrameworkTestKit#startAll] method to start required servicesvoid
startAll()
Before running tests, use this or [FrameworkTestKit#start] method to start required servicesakka.util.Timeout
timeout()
-
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 componentstestKitSettings
- custom testKitSettings- Returns:
- handle to FrameworkTestKit which can be used to start and stop all services started
-
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
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 servicesThis 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
-
configTestKit
-
eventTestKit
-
alarmTestKit
-
databaseTestKit
-
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
-
timeout
public akka.util.Timeout timeout() -
startAll
public void startAll()Before running tests, use this or [FrameworkTestKit#start] method to start required servicesThis 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 servicesThis 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 hcdbehaviorFactory
- behavior factory for the hcdlocationServiceUsage
- location service usages of the hcdconnections
- connections to track for the hcdinitializeTimeout
- 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 assemblybehaviorFactory
- behavior factory for the assemblylocationServiceUsage
- location service usages of the assemblyconnections
- connections to track for the assemblyinitializeTimeout
- initialize timeout for the assembly- Returns:
- actorRef of spawned assembly
-
shutdown
public void shutdown()Shutdown all testkits which are started.
-