org.aludratest.service.cmdline
Class CommandLineProcess<E extends CommandLineProcess<E>>

java.lang.Object
  extended by org.aludratest.service.cmdline.CommandLineProcess<E>
Type Parameters:
E - The child class, to be specified when inheriting the CommandLineProcess class

public class CommandLineProcess<E extends CommandLineProcess<E>>
extends Object

Business delegate class for creating and accessing a command line process.

Author:
Volker Bergmann

Constructor Summary
CommandLineProcess(String processType, String processName, CommandLineService service, int processTimeout, int responseTimeout, String... commands)
          Creates a CommandLineProcess instance.
 
Method Summary
 E assertExitValue(IntData expectedValue)
          Waits for the process to finish and asserts an exit value.
 E destroy()
          Kills the process
 E enter(StringData text)
          Sends the given text to the process' stdin.
 E enterLine(String text)
          Enters the provided text and appends a line feed.
 Out errOut()
           
 E setEnvironmentVariable(String key, String value)
          Sets an environment variable for the process.
 E setRelativeWorkingDirectory(String directoryPath)
          Sets the working directory of the process
 E start()
          Starts the process.
 StdIn stdIn()
           
 Out stdOut()
           
 String toString()
           
 E waitUntilFinished()
          Waits for the process to finish.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommandLineProcess

public CommandLineProcess(String processType,
                          String processName,
                          CommandLineService service,
                          int processTimeout,
                          int responseTimeout,
                          String... commands)
Creates a CommandLineProcess instance.

Parameters:
processType - the process type
processName - the process name
service - the underlying CommandLineService
processTimeout - the maximum time to wait for process termination
responseTimeout - the maximum time to wait for process response
commands - the commands used to start the process
Method Detail

setRelativeWorkingDirectory

public E setRelativeWorkingDirectory(String directoryPath)
Sets the working directory of the process

Parameters:
directoryPath - the path of the directory to be used
Returns:
this

setEnvironmentVariable

public E setEnvironmentVariable(String key,
                                String value)
Sets an environment variable for the process.

Parameters:
key -
value -
Returns:
this

start

public E start()
Starts the process.

Returns:
this

stdIn

public StdIn stdIn()
Returns:
the StdIn for processing the process' standard input

stdOut

public Out stdOut()
Returns:
the Out for the process' standard output

errOut

public Out errOut()
Returns:
the Out for the process' error output

enterLine

public E enterLine(String text)
Enters the provided text and appends a line feed.

Parameters:
text - the text to enter
Returns:
this

enter

public E enter(StringData text)
Sends the given text to the process' stdin.

Parameters:
text -
Returns:
this

waitUntilFinished

public E waitUntilFinished()
Waits for the process to finish.

Returns:
this

assertExitValue

public E assertExitValue(IntData expectedValue)
Waits for the process to finish and asserts an exit value.

Parameters:
expectedValue -
Returns:

destroy

public E destroy()
Kills the process

Returns:
this

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2015 aludratest.org. All rights reserved.