Class AbstractSerializingConnectorTest
java.lang.Object
test.de.iip_ecosphere.platform.connectors.AbstractSerializingConnectorTest
Generic re-usable test for serializing connectors, i.e., internal
byte[] types.- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classRe-used channeled serializer, ignoring the channel here.static interfaceAllows to configure the connector parameters.private static classJust counts product receptions. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract de.iip_ecosphere.platform.transport.connectors.TransportParameter.TransportParameterBuilderconfigureTransportParameter(de.iip_ecosphere.platform.transport.connectors.TransportParameter.TransportParameterBuilder builder) Configures the transport parameters used to connect the instance fromcreateConnector(ChannelProtocolAdapter...).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.protected de.iip_ecosphere.platform.connectors.ConnectorParametercreateConnectorParameter(de.iip_ecosphere.platform.support.ServerAddress addr, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer) Creates the coonnector parameter instance.protected abstract de.iip_ecosphere.platform.support.ServercreateTestServer(de.iip_ecosphere.platform.support.ServerAddress addr, File configDir) Creates the test server to test against.protected abstract de.iip_ecosphere.platform.transport.connectors.TransportConnectorReturns the transport connector to test against behind the test server.protected de.iip_ecosphere.platform.transport.connectors.TransportParametercreateTransportParameter(de.iip_ecosphere.platform.support.ServerAddress addr, test.de.iip_ecosphere.platform.transport.AbstractTransportConnectorTest.TransportParameterConfigurer configurer) Creates the transport parameter instance.protected voiddoTest(de.iip_ecosphere.platform.support.ServerAddress addr, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer) Implements a MQTT connector test.protected voiddoTestMultiChannel(de.iip_ecosphere.platform.support.ServerAddress addr, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer) Does a multi-channel test.protected abstract AbstractSerializingConnectorTest.ConnectorParameterConfigurergetConfigurer(boolean withTls) Returns the test configurer.protected abstract Class<? extends de.iip_ecosphere.platform.connectors.ConnectorDescriptor> Returns the connector descriptor forcreateConnector(ChannelProtocolAdapter...).protected abstract booleanReturns whether the connector implementation supports encryption.voidTests the connector through explicitly setting/resetting the factory implementation.private voidtestEnc(de.iip_ecosphere.platform.connectors.Connector<?, ?, ?, ?> connector, AbstractSerializingConnectorTest.ConnectorParameterConfigurer configurer, boolean connected) Tests encryption statements ofconnector, i.e.,Connector.supportedEncryption()andConnector.enabledEncryption().voidTests the TLS connector through explicitly setting/resetting the factory implementation.
-
Field Details
-
CMD_CHANNEL
- See Also:
-
PROD_CHANNEL
- See Also:
-
-
Constructor Details
-
AbstractSerializingConnectorTest
public AbstractSerializingConnectorTest()
-
-
Method Details
-
createConnector
protected abstract de.iip_ecosphere.platform.connectors.Connector<byte[],byte[], createConnectortest.de.iip_ecosphere.platform.transport.Product, test.de.iip_ecosphere.platform.transport.Command> (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 forcreateConnector(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 fromcreateConnector(ChannelProtocolAdapter...).- Parameters:
builder- the parameter builder- Returns:
builder
-
testConnector
Tests the connector through explicitly setting/resetting the factory implementation. Builds up aServerbased oncreateTestServer(ServerAddress, File)that the test is self-contained.- Throws:
IOException- in case that connection/communication fails
-
testTlsConnector
Tests the TLS connector through explicitly setting/resetting the factory implementation. Builds up aServerbased oncreateTestServer(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:
truefor supported,falsefor 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. UsesconfigureTransportParameter(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 ofconnector, i.e.,Connector.supportedEncryption()andConnector.enabledEncryption().- Parameters:
connector- the connector instance to testconfigurer- the configurer indicating whether encryption shall be activated if connectedconnected- whether the connector is supposed to be connected
-