Class Platform

java.lang.Object
org.opentestfactory.utils.shell.Platform
Direct Known Subclasses:
PosixPlatform, WindowsPlatform

public abstract class Platform extends Object
For testability, we encapsulate plateform-dependant behavior in a strategy family.
Author:
edegenetais
  • Constructor Details

    • Platform

      public Platform()
  • Method Details

    • getLocalPlatform

      public static final Platform getLocalPlatform()
      This function returns a Platform instance tuned to the local platform.
      Returns:
      the Platform instance.
    • getPlatformStatementSeparator

      public abstract String getPlatformStatementSeparator()
    • addShellSpawnCommandIfNeeded

      public String addShellSpawnCommandIfNeeded(String localCommand)
      Depending on what works or doesn't on the platform, may decide wether to open a shell. Opening a shell may be done for example in order to obtain shell interpreter functions that are unavailable when we are merely creating a new process wiht the first command part as executable name. Shell opening is performed by adding platform specific parts to the commandline before executing it.
      Parameters:
      localCommand - the local command string.
      Returns:
      the localCommand string with shell-opening part added.
    • isMultistatement

      protected boolean isMultistatement(String localCommand)
    • needsShellOnPlatform

      protected abstract boolean needsShellOnPlatform(String command)
    • prepareStatement

      protected abstract String prepareStatement(String query)
    • addStatementFromLine

      public void addStatementFromLine(Iterator<String> lineIterator, StringBuffer command)
      Perform platform-related changes to prepare the command string for execution.
      Parameters:
      lineIterator -
      command -
    • changeIntoInSHellCommand

      protected abstract String changeIntoInSHellCommand(String localCommand)