Class AbstractTestServiceManager
- java.lang.Object
-
- test.de.iip_ecosphere.platform.services.spring.AbstractTestServiceManager
-
- Direct Known Subclasses:
EnsembleStartStopServiceManagerTest,ServerStartStopServiceManagerTest,SimpleStartStopServiceManagerTest,ZipCpServiceManagerTest,ZipNoCpServiceManagerTest
public class AbstractTestServiceManager extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractTestServiceManager.ArtifactAsserterArtifact asserter interface.protected static classAbstractTestServiceManager.ServiceImplA fake service implementation for testing.
-
Field Summary
Fields Modifier and Type Field Description private static de.iip_ecosphere.platform.support.ServeraasServerprivate de.iip_ecosphere.platform.services.spring.SpringCloudServiceSetupconfigprivate static de.iip_ecosphere.platform.support.ServerimplServerprivate java.util.List<java.lang.String>netKeyToReleaseprivate static de.iip_ecosphere.platform.support.iip_aas.ActiveAasBase.NotificationModeoldMprivate static de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetupoldSetupprotected static java.util.function.Predicate<java.lang.Object>POSITIVE_GAUGE_VALUEA predicate testing whether the value of a JSON gauge is positive.private static de.iip_ecosphere.platform.support.Serverserverprivate java.util.List<de.iip_ecosphere.platform.support.Server>serversToRelease
-
Constructor Summary
Constructors Constructor Description AbstractTestServiceManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static voidassertFileExists(java.io.File file)Asserts thatfileexists.protected voidassertMetrics(java.lang.String[] ids, java.util.Map<java.lang.String,java.util.function.Predicate<java.lang.Object>> expected)Asserts the existence of selected AAS metrics and/or their values.protected static voidassertReceiverLog()Asserts the receiver log.protected voiddoTestStartStop(java.lang.String descriptorName, AbstractTestServiceManager.ArtifactAsserter asserter, boolean fakeServer)Implements the tests for a start-stop scenario with different descriptors/related asserters.protected de.iip_ecosphere.platform.services.spring.SpringCloudServiceSetupgetConfig()Returns the configuration instance.static voidinit(de.iip_ecosphere.platform.support.ServerAddress broker)Initializes the test by starting an embedded AMQP server.protected voidreleaseFakeServiceCommandServers()Release the servers created instartFakeServiceCommandServers(ServiceManager, String[]).static voidshutdown()Shuts down client and test server.protected voidstartFakeServiceCommandServers(de.iip_ecosphere.platform.services.ServiceManager mgr, java.lang.String[] ids)Starts fake service command servers to test the integration ofServiceStub.protected voidtestWithZipArchive(boolean useClasspath)Tests service start/stop with the ZIP artifact containing explicit dependency JARs.
-
-
-
Field Detail
-
POSITIVE_GAUGE_VALUE
protected static final java.util.function.Predicate<java.lang.Object> POSITIVE_GAUGE_VALUE
A predicate testing whether the value of a JSON gauge is positive.
-
server
private static de.iip_ecosphere.platform.support.Server server
-
oldM
private static de.iip_ecosphere.platform.support.iip_aas.ActiveAasBase.NotificationMode oldM
-
oldSetup
private static de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup oldSetup
-
implServer
private static de.iip_ecosphere.platform.support.Server implServer
-
aasServer
private static de.iip_ecosphere.platform.support.Server aasServer
-
config
@Autowired private de.iip_ecosphere.platform.services.spring.SpringCloudServiceSetup config
-
netKeyToRelease
private java.util.List<java.lang.String> netKeyToRelease
-
serversToRelease
private java.util.List<de.iip_ecosphere.platform.support.Server> serversToRelease
-
-
Method Detail
-
getConfig
protected de.iip_ecosphere.platform.services.spring.SpringCloudServiceSetup getConfig()
Returns the configuration instance.- Returns:
- the configuration instance
-
init
public static void init(de.iip_ecosphere.platform.support.ServerAddress broker)
Initializes the test by starting an embedded AMQP server. Requires the Qpid configuration file in src/test. We do not rely on MQTT here, because Moquette is not stable enough and Hivemq requires JDK 11.- Parameters:
broker- the broker address
-
shutdown
public static void shutdown()
Shuts down client and test server.
-
assertFileExists
protected static final void assertFileExists(java.io.File file)
Asserts thatfileexists.- Parameters:
file- the file
-
doTestStartStop
protected void doTestStartStop(java.lang.String descriptorName, AbstractTestServiceManager.ArtifactAsserter asserter, boolean fakeServer) throws java.util.concurrent.ExecutionException, java.io.IOExceptionImplements the tests for a start-stop scenario with different descriptors/related asserters.- Parameters:
descriptorName- the descriptor nameasserter- the asserter related to descriptor-specific propertiesfakeServer- fake command servers for services - clashes with services that are based on the service environment- Throws:
java.util.concurrent.ExecutionException- if executing service operations failsjava.io.IOException- if accessing metrics fails
-
assertReceiverLog
protected static void assertReceiverLog()
Asserts the receiver log.
-
assertMetrics
protected void assertMetrics(java.lang.String[] ids, java.util.Map<java.lang.String,java.util.function.Predicate<java.lang.Object>> expected) throws java.io.IOException, java.util.concurrent.ExecutionExceptionAsserts the existence of selected AAS metrics and/or their values.- Parameters:
ids- service idsexpected- the expected metrics as key-predicate pairs, whereby the predicate may be null to indicated that the value shall not be tested- Throws:
java.io.IOException- if the AAS cannot be retrievedjava.util.concurrent.ExecutionException- if a property cannot be queried
-
startFakeServiceCommandServers
protected void startFakeServiceCommandServers(de.iip_ecosphere.platform.services.ServiceManager mgr, java.lang.String[] ids)Starts fake service command servers to test the integration ofServiceStub.- Parameters:
mgr- the service managerids- the ids of the services to start
-
releaseFakeServiceCommandServers
protected void releaseFakeServiceCommandServers()
Release the servers created instartFakeServiceCommandServers(ServiceManager, String[]).
-
testWithZipArchive
protected void testWithZipArchive(boolean useClasspath) throws java.util.concurrent.ExecutionExceptionTests service start/stop with the ZIP artifact containing explicit dependency JARs.- Parameters:
useClasspath- consider classpath file- Throws:
java.util.concurrent.ExecutionException- shall not occur
-
-