lp.test.util
Class FakeProcess

java.lang.Object
  extended by java.lang.Process
      extended by lp.test.util.FakeProcess

public class FakeProcess
extends Process

A fake process class. Was used before but now it is here just for fun :o)

Version:
1.0.0
Author:
Martin Slota

Field Summary
private  int exit
          The exit value.
private  InputStream stderr
          The standard error InputStream.
private  OutputStream stdin
          The standard input OutputStream.
private  InputStream stdout
          The standard output InputStream.
 
Constructor Summary
FakeProcess(int exit)
          Creates a new instance with the given return value.
FakeProcess(String stdout, int exit)
          Creates a new instance with the given contents of standard output and and a given return value.
FakeProcess(String stdout, String stderr, int exit)
          Creates a new instance with the given contents of standard output and standard error streams and a given return value.
 
Method Summary
 void destroy()
          Has no effect.
 int exitValue()
          Returns the exit value of this fake process.
 InputStream getErrorStream()
          Returns the standard error InputStream of this fake process.
 InputStream getInputStream()
          Returns the standard output InputStream of this fake process.
 OutputStream getOutputStream()
          Returns the standard input OutputStream of this fake process.
 int waitFor()
          Returns the exit value of this fake process.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stdin

private final OutputStream stdin
The standard input OutputStream.


stdout

private final InputStream stdout
The standard output InputStream.


stderr

private final InputStream stderr
The standard error InputStream.


exit

private final int exit
The exit value.

Constructor Detail

FakeProcess

public FakeProcess(int exit)
Creates a new instance with the given return value. Standard output and standard error stream contents are set to an empty string and standard input is set to a black hole OutputStream.

Parameters:
exit - the return value of the new fake process

FakeProcess

public FakeProcess(String stdout,
                   int exit)
Creates a new instance with the given contents of standard output and and a given return value. Standard error contents are set to an empty string and standard input is set to a black hole OutputStream.

Parameters:
stdout - the contents of the standard output stream of the new process
exit - the return value of the new fake process

FakeProcess

public FakeProcess(String stdout,
                   String stderr,
                   int exit)
Creates a new instance with the given contents of standard output and standard error streams and a given return value. Standard input is set to a black hole OutputStream.

Parameters:
stdout - the contents of the standard output stream of the new fake process
stderr - the contents of the error output stream of the new fake process
exit - the return value of the new fake process
Method Detail

getOutputStream

public OutputStream getOutputStream()
Returns the standard input OutputStream of this fake process.

Specified by:
getOutputStream in class Process
Returns:
the standard input OutputStream of this fake process

getInputStream

public InputStream getInputStream()
Returns the standard output InputStream of this fake process.

Specified by:
getInputStream in class Process
Returns:
the standard output InputStream of this fake process

getErrorStream

public InputStream getErrorStream()
Returns the standard error InputStream of this fake process.

Specified by:
getErrorStream in class Process
Returns:
the standard error InputStream of this fake process

waitFor

public int waitFor()
Returns the exit value of this fake process.

Specified by:
waitFor in class Process
Returns:
the exit value of this fake process

exitValue

public int exitValue()
Returns the exit value of this fake process.

Specified by:
exitValue in class Process
Returns:
the exit value of this fake process

destroy

public void destroy()
Has no effect.

Specified by:
destroy in class Process