webtester.packages.threads
Class testCaseThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--webtester.packages.threads.testCaseThread
All Implemented Interfaces:
java.lang.Runnable

public class testCaseThread
extends java.lang.Thread

The thread that is used to execute test cases.

Author:
Aaron DeLong

Field Summary
private  boolean bDebug
          Indicates whether debugging is enabled.
private  boolean bFinished
          Indicates whether the thread has finished executing.
private  boolean bNotificationsEnabled
          Indicates whether notifications are enabled.
private  executionStats execInfo
          Used to accumulate execution statistics.
private  globalConfig gConfig
          Contains global configuration information.
private  org.apache.commons.httpclient.HostConfiguration hostConfiguration
          Stores configuration data for the http connection.
private  org.apache.commons.httpclient.HttpClient httpClient
          Used to make http connections, and obtain responses.
private  java.util.HashMap hVars
          Contains variable assignment values.
private static int iArgLen
          The number of command-line args to pass to the Tidy class.
private static int iHttpError
          The value at which http return codes indicate an error.
private static int iHttpPort
          The default http port.
private static int iSslPort
          The default SSL port.
private static int iTimeConversion
          Used to convert time values.
private static int iURLElement
          The starting index to use when parsing URLs.
private  org.apache.commons.httpclient.HttpMethod method
          Used to send GET requests.
private  org.apache.commons.httpclient.methods.MultipartPostMethod mpmethod
          Used for uploading files.
private  org.apache.commons.httpclient.methods.PostMethod pmethod
          Used to send POST requests.
private  java.lang.String sDescription
          Contains the description of the test case being executed.
private  java.lang.String sFormData
          Contains data sent to the URL, and is used in error notifications.
private  testCaseConfig tConfig
          Contains test case specified information.
private  int threadid
          A unique thread identifier.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
testCaseThread(globalConfig global, testCaseConfig testcase, java.lang.String sDesc, executionStats exec, int thrdid, java.lang.String sDebug)
          Constructor for the thread, which requires the objects necessary to execute a test case.
 
Method Summary
private  void examineResponse(java.lang.String sURL, java.lang.String sRegex, java.lang.String sVars, java.lang.String sMethod)
          Examine the response from the webserver, and send alerts if necessary.
 int getErrors()
          Read the error tracking file to get the total number of errors.
 int getMessagesSent()
          Retrieve the number of notifications sent by the application.
private  void incrementError()
          Increment the error count and udpate the file.
private  void incrementMessages()
          Increment the number of notifications sent by the application.
 boolean isFinished()
          Return the value which indicates if the thread is finished.
 void run()
          The method used to start executing a test case.
private  void sendData(java.lang.String sURL, java.lang.String sMethod, java.lang.String sData)
          Calls the given URL and checks for the correctness of data.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gConfig

private globalConfig gConfig
Contains global configuration information.


tConfig

private testCaseConfig tConfig
Contains test case specified information.


sDescription

private java.lang.String sDescription
Contains the description of the test case being executed.


hVars

private java.util.HashMap hVars
Contains variable assignment values.


method

private org.apache.commons.httpclient.HttpMethod method
Used to send GET requests.


pmethod

private org.apache.commons.httpclient.methods.PostMethod pmethod
Used to send POST requests.


mpmethod

private org.apache.commons.httpclient.methods.MultipartPostMethod mpmethod
Used for uploading files.


bDebug

private boolean bDebug
Indicates whether debugging is enabled.


bFinished

private boolean bFinished
Indicates whether the thread has finished executing.


bNotificationsEnabled

private boolean bNotificationsEnabled
Indicates whether notifications are enabled.


httpClient

private org.apache.commons.httpclient.HttpClient httpClient
Used to make http connections, and obtain responses.


hostConfiguration

private org.apache.commons.httpclient.HostConfiguration hostConfiguration
Stores configuration data for the http connection.


threadid

private int threadid
A unique thread identifier.


execInfo

private executionStats execInfo
Used to accumulate execution statistics.


iHttpError

private static final int iHttpError
The value at which http return codes indicate an error.

See Also:
Constant Field Values

iURLElement

private static final int iURLElement
The starting index to use when parsing URLs.

See Also:
Constant Field Values

iHttpPort

private static final int iHttpPort
The default http port.

See Also:
Constant Field Values

iSslPort

private static final int iSslPort
The default SSL port.

See Also:
Constant Field Values

iTimeConversion

private static final int iTimeConversion
Used to convert time values.

See Also:
Constant Field Values

sFormData

private java.lang.String sFormData
Contains data sent to the URL, and is used in error notifications.


iArgLen

private static final int iArgLen
The number of command-line args to pass to the Tidy class.

See Also:
Constant Field Values
Constructor Detail

testCaseThread

public testCaseThread(globalConfig global,
                      testCaseConfig testcase,
                      java.lang.String sDesc,
                      executionStats exec,
                      int thrdid,
                      java.lang.String sDebug)
Constructor for the thread, which requires the objects necessary to execute a test case.

Parameters:
global - an instance of the globalConfig object
testcase - an instance of the testCaseConfig object
sDesc - the String which describes the test caset
exec - an instance of executionStats, needed to calculate statistics
thrdid - an integer which identifies this thread
sDebug - a String which is used to determine if debugging output should be displayed
Method Detail

isFinished

public boolean isFinished()
Return the value which indicates if the thread is finished.

Returns:
FALSE if the thread is still executing

getErrors

public int getErrors()
Read the error tracking file to get the total number of errors.

Returns:
an integer which represents the number of errors

incrementError

private void incrementError()
Increment the error count and udpate the file.


getMessagesSent

public int getMessagesSent()
Retrieve the number of notifications sent by the application.

Returns:
an integer which is the number of messages sent by the application

incrementMessages

private void incrementMessages()
Increment the number of notifications sent by the application.


sendData

private void sendData(java.lang.String sURL,
                      java.lang.String sMethod,
                      java.lang.String sData)
Calls the given URL and checks for the correctness of data.

Parameters:
sURL - the URL to retrieve
sMethod - the method to use when submitting the URL, normally GET or POST
sData - the data to send when submitting the URL.

examineResponse

private void examineResponse(java.lang.String sURL,
                             java.lang.String sRegex,
                             java.lang.String sVars,
                             java.lang.String sMethod)
Examine the response from the webserver, and send alerts if necessary.

Parameters:
sURL - the URL that was called
sRegex - the regular expression which should be evaluated
sVars - any variable assignments which need to be performed if the regex is matched
sMethod - the method associated with the URL

run

public void run()
The method used to start executing a test case.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread