Class AbstractSerializingConnectorTest

java.lang.Object
test.de.iip_ecosphere.platform.connectors.AbstractSerializingConnectorTest

public abstract class AbstractSerializingConnectorTest extends Object
Generic re-usable test for serializing connectors, i.e., internal byte[] types.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • AbstractSerializingConnectorTest

      public AbstractSerializingConnectorTest()
  • Method Details

    • createConnector

      protected abstract de.iip_ecosphere.platform.connectors.Connector<byte[],byte[],test.de.iip_ecosphere.platform.transport.Product,test.de.iip_ecosphere.platform.transport.Command> createConnector(de.iip_ecosphere.platform.connectors.types.ChannelProtocolAdapter<byte[],byte[],test.de.iip_ecosphere.platform.transport.Product,test.de.iip_ecosphere.platform.transport.Command>... adapter)
      Creates the connector to be tested.
      Parameters:
      adapter - the protocol adapter(s) used to create the connector
      Returns:
      the connector instance
    • getConnectorDescriptor

      protected abstract Class<? extends de.iip_ecosphere.platform.connectors.ConnectorDescriptor> getConnectorDescriptor()
      Returns the connector descriptor for createConnector(ChannelProtocolAdapter...).
      Returns:
      the connector descriptor
    • createTestServer

      protected abstract de.iip_ecosphere.platform.support.Server createTestServer(de.iip_ecosphere.platform.support.ServerAddress addr, File configDir)
      Creates the test server to test against.
      Parameters:
      addr - the server address (schema may be ignored)
      configDir - specific configuration directory for this test server, may be null for none
      Returns:
      the server instance
    • createTransportConnector

      protected abstract de.iip_ecosphere.platform.transport.connectors.TransportConnector createTransportConnector()
      Returns the transport connector to test against behind the test server.
      Returns:
      the transport connector
    • configureTransportParameter

      protected abstract de.iip_ecosphere.platform.transport.connectors.TransportParameter.TransportParameterBuilder configureTransportParameter(de.iip_ecosphere.platform.transport.connectors.TransportParameter.TransportParameterBuilder builder)
      Configures the transport parameters used to connect the instance from createConnector(ChannelProtocolAdapter...).
      Parameters:
      builder - the parameter builder
      Returns:
      builder
    • testConnector

      public void testConnector() throws IOException
      Tests the connector through explicitly setting/resetting the factory implementation. Builds up a Server based on createTestServer(ServerAddress, File) that the test is self-contained.
      Throws:
      IOException - in case that connection/communication fails
    • testTlsConnector

      public void testTlsConnector() throws IOException
      Tests the TLS connector through explicitly setting/resetting the factory implementation. Builds up a Server based on createTestServer(ServerAddress, File) that the test is self-contained.
      Throws:
      IOException - in case that connection/communication fails
      See Also:
    • getConfigurer

      protected abstract AbstractSerializingConnectorTest.ConnectorParameterConfigurer getConfigurer(boolean withTls)
      Returns the test configurer.
      Parameters:
      withTls - shall a configurer for TLS tests be created
      Returns:
      the test configurer, may be null for none
    • implementsEncryption

      protected abstract boolean implementsEncryption()
      Returns whether the connector implementation supports encryption.
      Returns:
      true for supported, false for not supported
    • createConnectorParameter

      protected de.iip_ecosphere.platform.connectors.ConnectorParameter createConnectorParameter(de.iip_ecosphere.platform.support.ServerAddress addr, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer)
      Creates the coonnector parameter instance.
      Parameters:
      addr - the server address (schema is ignored)
      configurer - the parameter configurer, may be null for none
      Returns:
      the transport parameter
    • createTransportParameter

      protected de.iip_ecosphere.platform.transport.connectors.TransportParameter createTransportParameter(de.iip_ecosphere.platform.support.ServerAddress addr, test.de.iip_ecosphere.platform.transport.AbstractTransportConnectorTest.TransportParameterConfigurer configurer)
      Creates the transport parameter instance. Uses configureTransportParameter(TransportParameterBuilder) for basic, test-wide configuration.
      Parameters:
      addr - the server address (schema is ignored)
      configurer - the parameter configurer, may be null for none
      Returns:
      the transport parameter
    • doTest

      protected void doTest(de.iip_ecosphere.platform.support.ServerAddress addr, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer) throws IOException
      Implements a MQTT connector test.
      Parameters:
      addr - the server address (schema is ignored)
      configurer - the parameter configurer, may be null for none
      Throws:
      IOException - in case that connection/communication fails
    • doTestMultiChannel

      protected void doTestMultiChannel(de.iip_ecosphere.platform.support.ServerAddress addr, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer) throws IOException
      Does a multi-channel test.
      Parameters:
      addr - the server address (schema is ignored)
      configurer - the parameter configurer, may be null for none
      Throws:
      IOException - in case that connection/communication fails
    • testEnc

      private void testEnc(de.iip_ecosphere.platform.connectors.Connector<?,?,?,?> connector, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer, boolean connected)
      Tests encryption statements of connector, i.e., Connector.supportedEncryption() and Connector.enabledEncryption().
      Parameters:
      connector - the connector instance to test
      configurer - the configurer indicating whether encryption shall be activated if connected
      connected - whether the connector is supposed to be connected