ch.sf.htt
Class Httest

java.lang.Object
  extended by ch.sf.htt.Httest

public class Httest
extends java.lang.Object

Wrapper for running httest.


Field Summary
static java.lang.String ENV_ACTION_INHERIT
           
static java.lang.String ENV_ACTION_MERGE
           
static java.lang.String ENV_ACTION_REPLACE
           
static java.lang.String HTTEST_ENV
           
static java.lang.String HTTEST_HOME
           
static java.lang.String HTTEST_WORKDIR
           
static java.lang.String VERSION_PROPERTY
          Constant for name of system property which holds httest version.
 
Method Summary
 java.io.File getBinariesDir()
          Gets the binaries directory for httest binaries.
 Environment getEnvironment()
          Gets the environment to use when running httest.
 java.util.List<HttestError> getErrors()
          Returns the errors in case there was one.
 java.io.File getHtntlmFile()
          Gets file for htntlm executable.
static java.lang.String getHtntlmFilename()
          Gets file name of htntlm executable; "htntlm" on windows and "htntlm" on unix.
 java.io.File getHttestBinaryExecutableFile()
          Gets file for httest executable.
static java.lang.String getHttestBinaryExecutableFilename()
          Gets file name of httest executable; "httest.exe" on windows and "httest" on unix.
static OperatingSystem getOs()
          Return the current operating system.
 java.io.File getWorkingDir()
          Gets the working directory to use when running httest.
static Httest instance(java.io.File binariesDir, java.io.File workingDir, Environment environment)
          Creates a new Httest instance.
static Httest instance(java.util.Properties props)
          Convenience method for creating a new Httest instance from properties.
 void interruptExecution()
          Interrupts the executed process.
 boolean isInterrupted()
          Allows to check if this httest execution was interrupted.
 boolean isVerbose()
          Get info if httest output is verbose, i.e.
 ExecResult runScript(java.io.File scriptFile, java.lang.String... commandLineArgs)
          Run the script with the given file.
 ExecResult runScript(ITestListener console, java.io.File scriptFile, java.lang.String... commandLineArgs)
          Run the script with the given file.
 ExecResult runScript(ITestListener console, java.lang.String scriptFileName, java.lang.String... commandLineArgs)
          Run the script with the given file name, relative to the current working directory.
 ExecResult runScript(java.lang.String scriptFileName, java.lang.String... commandLineArgs)
          Run the script with the given file name and path, relative to the current working directory.
 void setEnvironment(Environment environment)
          Sets the environment to use when running httest.
 void setVerbose(boolean verbose)
          Set info if httest output is verbose, i.e.
 java.lang.String testBinary()
          Runs the httest binary with the argument "-V" and returns the version number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_PROPERTY

public static final java.lang.String VERSION_PROPERTY
Constant for name of system property which holds httest version.

See Also:
Constant Field Values

HTTEST_HOME

public static final java.lang.String HTTEST_HOME
See Also:
Constant Field Values

HTTEST_WORKDIR

public static final java.lang.String HTTEST_WORKDIR
See Also:
Constant Field Values

HTTEST_ENV

public static final java.lang.String HTTEST_ENV
See Also:
Constant Field Values

ENV_ACTION_INHERIT

public static final java.lang.String ENV_ACTION_INHERIT
See Also:
Constant Field Values

ENV_ACTION_REPLACE

public static final java.lang.String ENV_ACTION_REPLACE
See Also:
Constant Field Values

ENV_ACTION_MERGE

public static final java.lang.String ENV_ACTION_MERGE
See Also:
Constant Field Values
Method Detail

instance

public static Httest instance(java.io.File binariesDir,
                              java.io.File workingDir,
                              Environment environment)
Creates a new Httest instance.

Parameters:
binariesDir - Directory that contains httest binaries.
workingDir - Working directory when httest is run, relevant e.g. for _INCLUDE, if null means that use the current working directory.
environment - Environment to use, if null inherit from parent process.
Throws:
java.lang.RuntimeException - If the instance could not be created.

instance

public static Httest instance(java.util.Properties props)
Convenience method for creating a new Httest instance from properties. Mandatory Properties: - HTTEST_HOME: Directory path that contains httest binaries. Optional Properties: - HTTEST_WORKDIR: Directory path for working directory to use when running httest; default is current working directory. - HTTEST_ENV: What environment variables to use when running httest: - inherit: (Default) Inherit from parent process. - replace: Use only given properties as environment. - merge: Add given properties to inherited environment, replace variables that are already defined.

Returns:
The Httest instance.
Throws:
java.lang.IllegalArgumentException - If HTTEST_HOME is not defined.
java.lang.RuntimeException - If the instance could not be created.

runScript

public ExecResult runScript(java.io.File scriptFile,
                            java.lang.String... commandLineArgs)
                     throws java.io.IOException,
                            HttestFailedException
Run the script with the given file.

Parameters:
scriptFile - The file of the httest script to execute.
commandLineArgs - Optional command line arguments for the executed binary.
Throws:
java.io.IOException
HttestFailedException

runScript

public ExecResult runScript(java.lang.String scriptFileName,
                            java.lang.String... commandLineArgs)
                     throws java.io.IOException,
                            HttestFailedException
Run the script with the given file name and path, relative to the current working directory.

Parameters:
scriptFileName - The name of the httest script to execute.
commandLineArgs - Optional command line arguments for the executed binary.
Throws:
java.io.IOException
HttestFailedException

runScript

public ExecResult runScript(ITestListener console,
                            java.io.File scriptFile,
                            java.lang.String... commandLineArgs)
                     throws java.io.IOException,
                            HttestFailedException
Run the script with the given file.

Parameters:
console - The console output window (for the GUI). Is null in command-line mode.
scriptFile - The file of the httest script to execute.
commandLineArgs - Optional command line arguments for the executed binary.
Throws:
java.io.IOException
HttestFailedException

runScript

public ExecResult runScript(ITestListener console,
                            java.lang.String scriptFileName,
                            java.lang.String... commandLineArgs)
                     throws java.io.IOException,
                            HttestFailedException
Run the script with the given file name, relative to the current working directory.

Parameters:
console - The console output window (for the GUI). Is null in command-line mode.
scriptFileName - The name of the httest script to execute.
commandLineArgs - Optional command line arguments for the executed binary.
Throws:
java.io.IOException
HttestFailedException

testBinary

public java.lang.String testBinary()
                            throws java.io.IOException
Runs the httest binary with the argument "-V" and returns the version number.

Returns:
The version number, or null, if the binary could not be properly executed.
Throws:
java.io.IOException
java.lang.IllegalStateException

getErrors

public java.util.List<HttestError> getErrors()
Returns the errors in case there was one.

Returns:
The errors because of which the test failed.

interruptExecution

public void interruptExecution()
Interrupts the executed process.


isInterrupted

public boolean isInterrupted()
Allows to check if this httest execution was interrupted.

Returns:
True if the user interrupted the test.

getHttestBinaryExecutableFile

public java.io.File getHttestBinaryExecutableFile()
Gets file for httest executable.

Returns:
executable

getHttestBinaryExecutableFilename

public static java.lang.String getHttestBinaryExecutableFilename()
Gets file name of httest executable; "httest.exe" on windows and "httest" on unix.

Returns:
file name of httest executable

getHtntlmFile

public java.io.File getHtntlmFile()
Gets file for htntlm executable.

Returns:
executable

getHtntlmFilename

public static java.lang.String getHtntlmFilename()
Gets file name of htntlm executable; "htntlm" on windows and "htntlm" on unix.

Returns:
file name of htntlm executable

getBinariesDir

public java.io.File getBinariesDir()
Gets the binaries directory for httest binaries.

Returns:
the workingDir

getWorkingDir

public java.io.File getWorkingDir()
Gets the working directory to use when running httest.

Returns:
the workingDir

getEnvironment

public Environment getEnvironment()
Gets the environment to use when running httest.

Returns:
the environment

setEnvironment

public void setEnvironment(Environment environment)
Sets the environment to use when running httest.

Parameters:
environment - the environment to set

isVerbose

public boolean isVerbose()
Get info if httest output is verbose, i.e. if always printing out httest output or only in case httest failed.

Returns:
the verbose

setVerbose

public void setVerbose(boolean verbose)
Set info if httest output is verbose, i.e. if always printing out httest output or only in case httest failed.

Parameters:
verbose - the verbose to set

getOs

public static OperatingSystem getOs()
Return the current operating system.

Returns:
operating system