Class SimpleProcess
- java.lang.Object
-
- com.exasol.extensionmanager.itest.process.SimpleProcess
-
public class SimpleProcess extends Object
This is a convenient wrapper forProcessBuilderandProcessthat simplifies starting a process, waiting for it to finish and getting its stdout.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SimpleProcessstart(Path workingDirectory, List<String> command, ProcessStreamConsumer outputStreamConsumer, ProcessStreamConsumer errorStreamConsumer)Starts a new process.static Stringstart(Path workingDirectory, List<String> command, Duration executionTimeout)Starts a new process using the given working directory and waits until it terminates successfully.static SimpleProcessstart(List<String> command, ProcessStreamConsumer outputStreamConsumer, ProcessStreamConsumer errorStreamConsumer)Starts a new process using the working directory of the current Java process.static Stringstart(List<String> command, Duration executionTimeout)Starts a new process using the working directory of the current Java process and waits until it terminates successfully.voidstop()Destroy a running process.voidwaitUntilTerminatedSuccessfully(Duration executionTimeout)Wait for the process to terminate successfully.
-
-
-
Method Detail
-
start
public static String start(List<String> command, Duration executionTimeout)
Starts a new process using the working directory of the current Java process and waits until it terminates successfully.- Parameters:
command- command to executeexecutionTimeout- execution timeout for the process- Returns:
- combined stdout and stderr from the process
-
start
public static String start(Path workingDirectory, List<String> command, Duration executionTimeout)
Starts a new process using the given working directory and waits until it terminates successfully.- Parameters:
workingDirectory- directory in which to start the process. Use the working directory of the current Java process ifnull.command- command to executeexecutionTimeout- execution timeout for the process- Returns:
- combined stdout and stderr from the process
-
start
public static SimpleProcess start(List<String> command, ProcessStreamConsumer outputStreamConsumer, ProcessStreamConsumer errorStreamConsumer)
Starts a new process using the working directory of the current Java process.- Parameters:
command- command to executeoutputStreamConsumer-ProcessStreamConsumerfor the output streamerrorStreamConsumer-ProcessStreamConsumerfor the error stream- Returns:
- a new
SimpleProcessyou can use to wait for the process to finish and retrieve its output
-
start
public static SimpleProcess start(Path workingDirectory, List<String> command, ProcessStreamConsumer outputStreamConsumer, ProcessStreamConsumer errorStreamConsumer)
Starts a new process.- Parameters:
workingDirectory- directory in which to start the process. Use the working directory of the current Java process ifnullcommand- command to executeoutputStreamConsumer-ProcessStreamConsumerfor the output streamerrorStreamConsumer-ProcessStreamConsumerfor the error stream- Returns:
- a new
SimpleProcessyou can use to wait for the process to finish and retrieve its output
-
waitUntilTerminatedSuccessfully
public void waitUntilTerminatedSuccessfully(Duration executionTimeout)
Wait for the process to terminate successfully.- Parameters:
executionTimeout- maximum time to wait until the process finishes- Throws:
IllegalStateException- if the process did not finish within the given timeout or returned an exit code other than 0
-
stop
public void stop()
Destroy a running process.
-
-