Class AbstractInformationModelConnectorTest<D>

java.lang.Object
test.de.iip_ecosphere.platform.connectors.AbstractInformationModelConnectorTest<D>
Type Parameters:
D - the internal data type of the connector under test
All Implemented Interfaces:
MachineCommandInputTranslator.InputCustomizer, MachineDataOutputTranslator.OutputCustomizer

public abstract class AbstractInformationModelConnectorTest<D> extends Object implements MachineCommandInputTranslator.InputCustomizer, MachineDataOutputTranslator.OutputCustomizer
Implements a re-usable information model connector test.
Author:
Holger Eichelberger, SSE
  • Field Details

    • LOGGER

      private static final de.iip_ecosphere.platform.support.logging.Logger LOGGER
    • dataType

      private Class<? extends D> dataType
  • Constructor Details

    • AbstractInformationModelConnectorTest

      protected AbstractInformationModelConnectorTest(Class<? extends D> dataType)
      Creates an instance and sets the internal data type.
      Parameters:
      dataType - the internal data type
  • Method Details

    • getConnectorDescriptor

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

      protected abstract void assertAdditionalProperties(AbstractInformationModelConnectorTest.Step step, MachineData received)
      Asserts additional properties for the given step of testing.
      Parameters:
      step - the testing step
      received - the received machine data from the connector
    • afterActions

      protected abstract void afterActions(de.iip_ecosphere.platform.connectors.Connector<D,Object,MachineData,MachineCommand> connector)
      Do additional actions after testing.
      Parameters:
      connector - the connector instance
    • createConnector

      protected abstract de.iip_ecosphere.platform.connectors.Connector<D,Object,MachineData,MachineCommand> createConnector(de.iip_ecosphere.platform.connectors.types.ProtocolAdapter<D,Object,MachineData,MachineCommand> adapter)
      Creates the connector to be tested.
      Parameters:
      adapter - the protocol adapter to use
      Returns:
      the connector instance to test
    • getConnectorParameter

      protected abstract de.iip_ecosphere.platform.connectors.ConnectorParameter getConnectorParameter()
      Returns the connector parameters for Connector.connect(ConnectorParameter).
      Returns:
      the connector parameters
    • testConnector

      public void testConnector(boolean withNotifications) throws IOException
      Tests the connector.
      Parameters:
      withNotifications - operate with/without notifications (for testing)
      Throws:
      IOException - in case that creating the connector fails
    • block

      protected void block(AtomicInteger count, int receptions)
      Blocks until a certain number of (accumulated) receptions is reached or fails after 4s.
      Parameters:
      count - the counter
      receptions - the expected number of receptions