Package csw.testkit.javadsl
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 Summary
ConstructorDescriptionInitialize testkit with default configurationFrameworkTestKitJunitResource
(akka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command> actorSystem) Initialize testkit with provided actorSystemFrameworkTestKitJunitResource
(FrameworkTestKit frameworkTestKit, List<csw.testkit.scaladsl.CSWService> services) FrameworkTestKitJunitResource
(List<csw.testkit.scaladsl.CSWService> services) Initialize testkit and start all the provided services. -
Method Summary
Modifier and TypeMethodDescriptionakka.actor.typed.ActorSystem<akka.actor.typed.SpawnProtocol.Command>
void
after()
Shuts down the FrameworkTestKitvoid
before()
Start FrameworkTestKitakka.actor.typed.ActorRef<ContainerMessage>
spawnContainer
(com.typesafe.config.Config config) Delegate to framework testkitakka.actor.typed.ActorRef<ComponentMessage>
spawnStandalone
(com.typesafe.config.Config config) Delegate to framework testkitMethods inherited from class org.junit.rules.ExternalResource
apply
-
Constructor Details
-
FrameworkTestKitJunitResource
public FrameworkTestKitJunitResource(FrameworkTestKit frameworkTestKit, List<csw.testkit.scaladsl.CSWService> services) -
FrameworkTestKitJunitResource
public FrameworkTestKitJunitResource()Initialize testkit with default configurationBy 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
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 classorg.junit.rules.ExternalResource
-
before
public void before()Start FrameworkTestKit- Overrides:
before
in classorg.junit.rules.ExternalResource
-
frameworkTestKit
-
jEventService
-
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
-