Class PythonEnvironmentTest

java.lang.Object
test.de.iip_ecosphere.platform.services.environment.AbstractEnvironmentTest
test.de.iip_ecosphere.platform.services.environment.PythonEnvironmentTest

public class PythonEnvironmentTest extends AbstractEnvironmentTest
Integration test for the Python environment.
Author:
Sakshi Singh, SSE
  • Constructor Details

    • PythonEnvironmentTest

      public PythonEnvironmentTest()
  • Method Details

    • setup

      public void setup()
      Sets up plugins. Non-static so that loading is inherited.
    • redirectIO

      private static void redirectIO(InputStream src, PrintStream dest, Consumer<String> cons)
      Redirects an input stream to another stream (in parallel).
      Parameters:
      src - the source stream
      dest - the destination stream
      cons - optional consumer to analyze received lines, may be null for none
    • createPythonProcess

      public static Process createPythonProcess(File dir, String... args) throws IOException
      Creates and starts a Python process.
      Parameters:
      dir - the home dir where to find the script/run it within
      args - the process arguments for the script including python arguments (first), script and script arguments
      Returns:
      the created process
      Throws:
      IOException - if process creation fails
    • createPythonProcess

      public static Process createPythonProcess(File dir, Consumer<String> stdCons, Consumer<String> errCons, String... args) throws IOException
      Creates and starts a Python process.
      Parameters:
      dir - the home dir where to find the script/run it within
      stdCons - optional consumer on standard out, may be null
      errCons - optional consumer on standard error, may be null
      args - the process arguments for the script including python arguments (first), script and script arguments
      Returns:
      the created process
      Throws:
      IOException - if process creation fails
    • createPythonProcess

      public static Process createPythonProcess(String... args) throws IOException
      Creates and starts a Python process with home directory "./src/test/python".
      Parameters:
      args - the process arguments for the script including python arguments (first), script and script arguments
      Returns:
      the created process
      Throws:
      IOException - if process creation fails
    • createPythonProcess

      public static Process createPythonProcess(Consumer<String> stdCons, Consumer<String> errCons, String... args) throws IOException
      Creates and starts a Python process with home directory "./src/test/python".
      Parameters:
      stdCons - optional consumer on standard out, may be null
      errCons - optional consumer on standard error, may be null
      args - the process arguments for the script including python arguments (first), script and script arguments
      Returns:
      the created process
      Throws:
      IOException - if process creation fails
    • testPythonEnvironment

      public void testPythonEnvironment() throws IOException, ExecutionException
      Tests the Python implementation.
      Throws:
      IOException - shall not occur
      ExecutionException - shall not occur
    • testPythonEnvironment

      private void testPythonEnvironment(String protocol) throws IOException, ExecutionException
      Tests the Python implementation.
      Parameters:
      protocol - the AAS implementation protocol (see AasFactory.getProtocols()
      Throws:
      IOException - shall not occur
      ExecutionException - shall not occur