Class FileConnectorTest
java.lang.Object
test.de.oktoflow.platform.connectors.file.FileConnectorTest
Implements a test for
FileConnector.- Author:
- Holger Eichelberger, SSE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringcomposeTmpPath(String postfix) Composes a temporary path.private 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.transport.serialization.Serializer<test.de.iip_ecosphere.platform.transport.Product> outSer, de.iip_ecosphere.platform.transport.serialization.Serializer<test.de.iip_ecosphere.platform.transport.Command> inSer, boolean determineTimeDiff) Creates a connector.private static File[]deleteTmpConnectorFiles(String writeFiles) Deletes temporary connector files fromlistTmpConnectorFiles(boolean)without considering the current thread id.private static FilefindNewConnectorFile(File[] before, String writeFiles) Finds the new connector file written by the connector.private static File[]listTmpConnectorFiles(boolean considerThread) Lists all temporary connector files (in temp).private voidtestConnector(String readFiles, String writeFiles, int expectedReceived, boolean determineTimeDiff) Tests a file connector by reading and if set up writing.voidTests a multiple files in a directory.voidTests a multiple files in a directory selected by regEx.voidTests a single file.voidTests a single file as resource.
-
Constructor Details
-
FileConnectorTest
public FileConnectorTest()
-
-
Method Details
-
createConnector
private 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.transport.serialization.Serializer<test.de.iip_ecosphere.platform.transport.Product> outSer, de.iip_ecosphere.platform.transport.serialization.Serializer<test.de.iip_ecosphere.platform.transport.Command> inSer, boolean determineTimeDiff) Creates a connector.- Parameters:
outSer- the output serializer to useinSer- the input serializer to usedetermineTimeDiff- shall a data dependent time difference be applied/simulated- Returns:
- the connector instance
-
composeTmpPath
Composes a temporary path.- Parameters:
postfix- the path postfix after the temporary folder, e.g., a file name, may be empty- Returns:
- the composed path
-
testSingleFile
Tests a single file.- Throws:
IOException- shall not occur
-
testSingleFileResource
Tests a single file as resource.- Throws:
IOException- shall not occur
-
testMultipleFiles
Tests a multiple files in a directory.- Throws:
IOException- shall not occur
-
testRegExFiles
Tests a multiple files in a directory selected by regEx.- Throws:
IOException- shall not occur
-
listTmpConnectorFiles
Lists all temporary connector files (in temp).- Parameters:
considerThread- shall the current thread id be considered when finding the files or shall all be returned- Returns:
- the files found, may be null for none
-
deleteTmpConnectorFiles
Deletes temporary connector files fromlistTmpConnectorFiles(boolean)without considering the current thread id. IfwriteFilesis given and an existing file, also try to delete that file.- Parameters:
writeFiles- the test file/folder to be written by the connector, may be empty/null- Returns:
- the temp files deleted and identified to exist before, except for
writeFiles
-
findNewConnectorFile
Finds the new connector file written by the connector.- Parameters:
before- the temporary files existing before the test,deleteTmpConnectorFiles(String).writeFiles- the test file/folder to be written by the connector, may be empty/null; takes precedence if given- Returns:
- the file written by the connector, may be null for none
-
testConnector
private void testConnector(String readFiles, String writeFiles, int expectedReceived, boolean determineTimeDiff) throws IOException Tests a file connector by reading and if set up writing.- Parameters:
readFiles- the files to read as file name, folder name or file/folder-regexwriteFiles- the files to write as file name or folder name, may be nullexpectedReceived- expected number of received data pointsdetermineTimeDiff- shall a data dependent time difference be applied/simulated- Throws:
IOException
-