Class AasTest


  • public class AasTest
    extends java.lang.Object
    Tests the AAS abstraction with server and client on the "same machine".
    Author:
    Monika Staciwa, SSE, Holger Eichelberger, SSE
    • Field Detail

      • QNAME_VAR_LOTSIZE

        public static final java.lang.String QNAME_VAR_LOTSIZE
      • QNAME_VAR_VENDOR

        public static final java.lang.String QNAME_VAR_VENDOR
      • QNAME_VAR_POWCONSUMPTION

        public static final java.lang.String QNAME_VAR_POWCONSUMPTION
      • QNAME_OP_STARTMACHINE

        public static final java.lang.String QNAME_OP_STARTMACHINE
      • QNAME_OP_RECONFIGURE

        public static final java.lang.String QNAME_OP_RECONFIGURE
      • QNAME_OP_STOPMACHINE

        public static final java.lang.String QNAME_OP_STOPMACHINE
      • NAME_SUBMODELC_OUTER

        private static final java.lang.String NAME_SUBMODELC_OUTER
        See Also:
        Constant Field Values
      • NAME_VAR_SUBMODELC_OUTER_VAR

        private static final java.lang.String NAME_VAR_SUBMODELC_OUTER_VAR
        See Also:
        Constant Field Values
      • NAME_VAR_SUBMODELC_OUTER_REF

        private static final java.lang.String NAME_VAR_SUBMODELC_OUTER_REF
        See Also:
        Constant Field Values
      • NAME_SUBMODELC_INNER

        private static final java.lang.String NAME_SUBMODELC_INNER
        See Also:
        Constant Field Values
      • NAME_VAR_SUBMODELC_INNER_VAR

        private static final java.lang.String NAME_VAR_SUBMODELC_INNER_VAR
        See Also:
        Constant Field Values
      • NAME_VAR_SUBMODELC_INNER_INT

        private static final java.lang.String NAME_VAR_SUBMODELC_INNER_INT
        See Also:
        Constant Field Values
      • NAME_VAR_SUBMODELC_INNER_REF

        private static final java.lang.String NAME_VAR_SUBMODELC_INNER_REF
        See Also:
        Constant Field Values
      • NAME_VAR_LOTSIZE

        private static final java.lang.String NAME_VAR_LOTSIZE
        See Also:
        Constant Field Values
      • NAME_VAR_POWCONSUMPTION

        private static final java.lang.String NAME_VAR_POWCONSUMPTION
        See Also:
        Constant Field Values
      • NAME_VAR_DESCRIPTION1

        private static final java.lang.String NAME_VAR_DESCRIPTION1
        See Also:
        Constant Field Values
      • NAME_VAR_DESCRIPTION2

        private static final java.lang.String NAME_VAR_DESCRIPTION2
        See Also:
        Constant Field Values
      • NAME_OP_STARTMACHINE

        private static final java.lang.String NAME_OP_STARTMACHINE
        See Also:
        Constant Field Values
      • NAME_OP_RECONFIGURE

        private static final java.lang.String NAME_OP_RECONFIGURE
        See Also:
        Constant Field Values
      • NAME_OP_STOPMACHINE

        private static final java.lang.String NAME_OP_STOPMACHINE
        See Also:
        Constant Field Values
      • VAB_SERVER

        private static final de.iip_ecosphere.platform.support.ServerAddress VAB_SERVER
    • Constructor Detail

      • AasTest

        public AasTest()
    • Method Detail

      • createOperationsServer

        public static de.iip_ecosphere.platform.support.Server createOperationsServer​(int port,
                                                                                      TestMachine machine,
                                                                                      java.lang.String protocol,
                                                                                      de.iip_ecosphere.platform.support.net.KeyStoreDescriptor kstore)
        Creates the operations server for the given machine instance and for the operations in createAasOperationsElements(SubmodelElementContainerBuilder, String, int, String).
        Parameters:
        port - the server communication port
        machine - the machine
        protocol - the VAB protocol as used in AasFactory
        kstore - the keystore descriptor, ignored if null
        Returns:
        the protocol server
      • createAasOperationsElements

        public void createAasOperationsElements​(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder subModelBuilder,
                                                de.iip_ecosphere.platform.support.ServerAddress addr,
                                                java.lang.String protocol)
        Parameters:
        subModelBuilder - the sub model container builder to add the elements to
        addr - the server address (schema ignored)
        protocol - the VAB protocol as used in AasFactory
      • createAasOperationsElements

        public void createAasOperationsElements​(de.iip_ecosphere.platform.support.aas.SubmodelElementContainerBuilder subModelBuilder,
                                                java.lang.String host,
                                                int port,
                                                java.lang.String protocol)
        Parameters:
        subModelBuilder - the sub model container builder to add the elements to
        host - the protocol host
        port - the protocol port
        protocol - the VAB protocol as used in AasFactory
      • testVabQuery

        public void testVabQuery()
                          throws java.net.SocketException,
                                 java.net.UnknownHostException,
                                 java.util.concurrent.ExecutionException,
                                 java.io.IOException
        Tests creating/reading an AAS over all protocols of a factory.
        Throws:
        java.net.SocketException - shall not occur if the test works
        java.net.UnknownHostException - shall not occur if the test works
        java.util.concurrent.ExecutionException - shall not occur if the test works
        java.io.IOException - shall not occur if the test works
      • getServerProtocols

        public java.lang.String[] getServerProtocols()
        Returns the server protocols to use during test.
        Returns:
        the server protocols, empty for HTTP/unencrypted
      • getKeyStoreDescriptor

        protected de.iip_ecosphere.platform.support.net.KeyStoreDescriptor getKeyStoreDescriptor​(java.lang.String protocol)
        To be overridden: descriptor for keystore per protocol.
        Parameters:
        protocol - the protocol
        Returns:
        the keystore, may be null for none
      • excludeProtocol

        protected boolean excludeProtocol​(java.lang.String protocol)
        To be overridden: Exclude the given protocol from testing.
        Parameters:
        protocol - the protocol
        Returns:
        true for exclusion, false for inclusion
      • testVabQuery

        protected void testVabQuery​(java.lang.String protocol,
                                    java.lang.String serverProtocol)
                             throws java.net.SocketException,
                                    java.net.UnknownHostException,
                                    java.util.concurrent.ExecutionException,
                                    java.io.IOException
        Tests creating/reading an AAS.
        Parameters:
        protocol - the VAB protocol as used in AasFactory
        serverProtocol - use server protocols to use, empty string for HTTP, rest see AasFactory
        Throws:
        java.net.SocketException - shall not occur if the test works
        java.net.UnknownHostException - shall not occur if the test works
        java.util.concurrent.ExecutionException - shall not occur if the test works
        java.io.IOException - shall not occur if the test works
      • createAas

        private de.iip_ecosphere.platform.support.aas.Aas createAas​(TestMachine machine,
                                                                    java.lang.String protocol)
                                                             throws java.net.SocketException,
                                                                    java.net.UnknownHostException
        This method creates a test Asset Administration Shell.
        Parameters:
        machine - the test machine instance
        protocol - the VAB protocol as used in AasFactory
        Returns:
        the created AAS
        Throws:
        java.net.SocketException - if the port to be used for the AAS is occupied
        java.net.UnknownHostException - shall not occur
      • assertLangString

        private static void assertLangString​(java.lang.Object val,
                                             java.lang.String str)
        Asserts lang string equality.
        Parameters:
        val - the value of a property
        str - the (composed) lang string to test for
      • queryAas

        private static void queryAas​(de.iip_ecosphere.platform.support.Endpoint registry,
                                     TestMachine machine)
                              throws java.util.concurrent.ExecutionException,
                                     java.io.IOException
        Queries the created AAS.
        Parameters:
        registry - the registry to get the machine AAS from
        machine - the test machine as reference
        Throws:
        java.util.concurrent.ExecutionException - if operation invocations fail
        java.io.IOException - if retrieving the AAS fails
      • assertSize

        private static <T> void assertSize​(int expectedSize,
                                           java.lang.Iterable<T> iter)
        Asserts an iterator contents (just) by counting the number of elements.
        Type Parameters:
        T - the element type
        Parameters:
        expectedSize - the expected size
        iter - the iterator to assert
      • testFactory

        public void testFactory()
        Tests the factory.
      • testIllegalShortId

        public void testIllegalShortId()
        Tests for illegal short ids. Seems to be valid for all AAs.
      • testFixId

        public void testFixId()
        Tests AasFactory.fixId(String) for BaSyX.