Class FileConnectorTest

java.lang.Object
test.de.oktoflow.platform.connectors.file.FileConnectorTest

public class FileConnectorTest extends Object
Implements a test for FileConnector.
Author:
Holger Eichelberger, SSE
  • Constructor Details

    • FileConnectorTest

      public FileConnectorTest()
  • Method Details

    • createConnector

      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.
      Parameters:
      outSer - the output serializer to use
      inSer - the input serializer to use
      determineTimeDiff - shall a data dependent time difference be applied/simulated
      Returns:
      the connector instance
    • composeTmpPath

      private static String composeTmpPath(String postfix)
      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

      public void testSingleFile() throws IOException
      Tests a single file.
      Throws:
      IOException - shall not occur
    • testSingleFileResource

      public void testSingleFileResource() throws IOException
      Tests a single file as resource.
      Throws:
      IOException - shall not occur
    • testMultipleFiles

      public void testMultipleFiles() throws IOException
      Tests a multiple files in a directory.
      Throws:
      IOException - shall not occur
    • testRegExFiles

      public void testRegExFiles() throws IOException
      Tests a multiple files in a directory selected by regEx.
      Throws:
      IOException - shall not occur
    • listTmpConnectorFiles

      private static File[] listTmpConnectorFiles(boolean considerThread)
      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

      private static File[] deleteTmpConnectorFiles(String writeFiles)
      Deletes temporary connector files from listTmpConnectorFiles(boolean) without considering the current thread id. If writeFiles is 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

      private static File findNewConnectorFile(File[] before, String writeFiles)
      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-regex
      writeFiles - the files to write as file name or folder name, may be null
      expectedReceived - expected number of received data points
      determineTimeDiff - shall a data dependent time difference be applied/simulated
      Throws:
      IOException