Package net.morimekta.testing
Class IntegrationExecutor
- java.lang.Object
-
- net.morimekta.testing.IntegrationExecutor
-
public class IntegrationExecutor extends java.lang.ObjectHelper to handle process forking related to testing a jar file.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIntegrationExecutor(java.io.File jarFile)IntegrationExecutor(java.lang.String module, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetError()java.lang.StringgetOutput()intrun(java.lang.String... args)Run the program with the specified arguments.voidsetDeadlineMs(long deadlineMs)Set the program deadline.voidsetDirectory(java.io.File directory)Set the working directory for the execution.voidsetInput(java.io.InputStream in)Set input stream to write to the process as program input.
-
-
-
Method Detail
-
getOutput
public java.lang.String getOutput()
- Returns:
- The programs stdout content.
-
getError
public java.lang.String getError()
- Returns:
- The programs stderr content.
-
setInput
public void setInput(java.io.InputStream in)
Set input stream to write to the process as program input.- Parameters:
in- The program input.
-
setDeadlineMs
public void setDeadlineMs(long deadlineMs)
Set the program deadline. If not finished in this time interval, the run fails with an IOException.- Parameters:
deadlineMs- The new deadline in milliseconds. 0 means to wait forever. Default is 1 second.
-
setDirectory
public void setDirectory(java.io.File directory)
Set the working directory for the execution.- Parameters:
directory- The CWD for the executiron.
-
run
public int run(java.lang.String... args) throws java.io.IOExceptionRun the program with the specified arguments.- Parameters:
args- The arguments.- Returns:
- The programs exit code.
- Throws:
java.io.IOException- If the run times out or is interrupted.
-
-