|
OOoRunner test harness | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--helper.ProcessHandler
Class provides convenient way for running external program handle its standard streams, control execution and check results. Instance of this class must be created only for a single execution. If you need to execute the same command again you should create a new instance for this.
Constructor Summary | |
ProcessHandler(String cmdLine)
Creates instance with specified external command. |
|
ProcessHandler(String cmdLine,
File workDir)
Creates instance with specified external command which will be executed in the some work directory. |
|
ProcessHandler(String cmdLine,
PrintWriter log)
Creates instance with specified external command and log stream where debug info is printed and output of external command. |
|
ProcessHandler(String cmdLine,
PrintWriter log,
File workDir,
String[] envVars)
Creates instance with specified external command which will be executed in the some work directory and log stream where debug info and output of external command is printed . |
|
ProcessHandler(String cmdLine,
PrintWriter log,
File workDir,
String[] envVars,
long timeOut)
Creates instance with specified external command which will be executed in the some work directory and |
Method Summary | |
protected void |
execute()
|
boolean |
executeAsynchronously()
Executes the command immediately returns. |
boolean |
executeSynchronously()
Executes the command and returns only when the process exits. |
protected void |
flushInput()
|
String |
getErrorText()
Returns the text output by external command to stderr. |
int |
getExitCode()
Returns exit code of the external command. |
String |
getOutputText()
Returns the text output by external command to stdout. |
boolean |
isFinished()
Returns the information about the final state of command execution. |
boolean |
isStarted()
Returns information about was the command started or not. |
boolean |
isTimedOut()
|
void |
kill()
|
void |
printInputText(String str)
Prints the string specified to sdtin of external command. |
boolean |
waitFor()
This method is useful when the process was executed asynchronously. |
boolean |
waitFor(long timeout)
This method is useful when the process was executed asynchronously. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ProcessHandler(String cmdLine)
public ProcessHandler(String cmdLine, PrintWriter log)
public ProcessHandler(String cmdLine, File workDir)
public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars)
public ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars, long timeOut)
log
- log stream where debug info and output
of external command is printed .workDir
- The working directory of the new processenvVars
- The specified environment variables are
set for the new process.
If log stream is null, logging is printed to stdout.timeOut
- When started sychronisly, the maximum time the
process will live. When the process being destroyed
a log will be written out. It can be asked on
isTimedOut()
if it has been terminated.
timeOut > 0
Waits specified time in miliSeconds for
process to exit and return its status.
timeOut = 0
Waits for the process to end regulary
timeOut < 0
Kills the process immediatelyMethod Detail |
public boolean isTimedOut()
public boolean executeSynchronously()
true
if process was successfully
started and correcly exits (exit code doesn't affect
to this result).public boolean executeAsynchronously()
waitFor
methods.true
if process was successfully
started.public void kill()
protected void execute()
public boolean waitFor()
true
if process correctly exited
(exit code doesn't affect to this result).public boolean waitFor(long timeout)
timeOut
- > 0
Waits specified time in miliSeconds for
process to exit and return its status.
= 0
Waits for the process to end regulary
< 0
Kills the process immediatelytrue
if process correctly exited
(exit code doesn't affect to this result).protected void flushInput()
public String getOutputText()
public String getErrorText()
public void printInputText(String str)
The method can also be called before the command starts its execution. Then the text is buffered and transfered to command when it will be started.
public boolean isStarted()
true
if the external command was
found and successfully started.public boolean isFinished()
true
if the command correctly starts,
exits and was not interrupted due to timeout.public int getExitCode()
|
OOoRunner test harness | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |