Class AbstractTestServiceManager

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static de.iip_ecosphere.platform.support.Server aasServer  
      private de.iip_ecosphere.platform.services.spring.SpringCloudServiceSetup config  
      private static de.iip_ecosphere.platform.support.Server implServer  
      private java.util.List<java.lang.String> netKeyToRelease  
      private static de.iip_ecosphere.platform.support.iip_aas.ActiveAasBase.NotificationMode oldM  
      private static de.iip_ecosphere.platform.support.iip_aas.AasPartRegistry.AasSetup oldSetup  
      protected static java.util.function.Predicate<java.lang.Object> POSITIVE_GAUGE_VALUE
      A predicate testing whether the value of a JSON gauge is positive.
      private static de.iip_ecosphere.platform.support.Server server  
      private java.util.List<de.iip_ecosphere.platform.support.Server> serversToRelease  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static void assertFileExists​(java.io.File file)
      Asserts that file exists.
      protected void assertMetrics​(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 void assertReceiverLog()
      Asserts the receiver log.
      protected void doTestStartStop​(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.SpringCloudServiceSetup getConfig()
      Returns the configuration instance.
      static void init​(de.iip_ecosphere.platform.support.ServerAddress broker)
      Initializes the test by starting an embedded AMQP server.
      protected void releaseFakeServiceCommandServers()
      static void shutdown()
      Shuts down client and test server.
      protected void startFakeServiceCommandServers​(de.iip_ecosphere.platform.services.ServiceManager mgr, java.lang.String[] ids)
      Starts fake service command servers to test the integration of ServiceStub.
      protected void testWithZipArchive​(boolean useClasspath)
      Tests service start/stop with the ZIP artifact containing explicit dependency JARs.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • Constructor Detail

      • AbstractTestServiceManager

        public AbstractTestServiceManager()
    • 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 that file exists.
        Parameters:
        file - the file
      • doTestStartStop

        protected void doTestStartStop​(java.lang.String descriptorName,
                                       AbstractTestServiceManager.ArtifactAsserter asserter,
                                       boolean fakeServer)
                                throws java.util.concurrent.ExecutionException,
                                       java.io.IOException
        Implements the tests for a start-stop scenario with different descriptors/related asserters.
        Parameters:
        descriptorName - the descriptor name
        asserter - the asserter related to descriptor-specific properties
        fakeServer - fake command servers for services - clashes with services that are based on the service environment
        Throws:
        java.util.concurrent.ExecutionException - if executing service operations fails
        java.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.ExecutionException
        Asserts the existence of selected AAS metrics and/or their values.
        Parameters:
        ids - service ids
        expected - 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 retrieved
        java.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 of ServiceStub.
        Parameters:
        mgr - the service manager
        ids - the ids of the services to start
      • testWithZipArchive

        protected void testWithZipArchive​(boolean useClasspath)
                                   throws java.util.concurrent.ExecutionException
        Tests service start/stop with the ZIP artifact containing explicit dependency JARs.
        Parameters:
        useClasspath - consider classpath file
        Throws:
        java.util.concurrent.ExecutionException - shall not occur