|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--webtester.packages.threads.proxyHandler
The thread that is used for proxying HTTP requests, and examining the responses.
Field Summary | |
private java.util.ArrayList |
aExcludeList
Contains a list of regular expressions to exclude while recording. |
private java.util.ArrayList |
aRegexes
Contains regular expressions recorded with a test case. |
private boolean |
bEndProxy
Inidicates whether the proxy has finished recording. |
private boolean |
bImageRecord
Indicates whether images are being recorded. |
private boolean |
bPostRedirect
Indicates whether a POST request resulted in a redirect request. |
private boolean |
bRecord
Indicates whether the proxy is recording a test case. |
private boolean |
bSSL
Indicates whether the user attempted to make an SSL connection. |
private java.util.HashMap |
hHeaders
Contains HTTP headers sent by the browser. |
private java.util.HashMap |
hServerTypes
Indicates the type of webserver being accessed. |
private static int |
iAllowedTries
The number of allowed tries for reading data from a socket. |
private static int |
iDefaultPort
The default port to use for HTTP connections. |
private static int |
iDefaultTimeout
The default timeout value for HTTP connections. |
private static int |
iHeaderLimit
The minimum allowed length for http headers before they will be parsed. |
private static int |
iHttpError
The value at which HTTP return codes indicate an error. |
private static int |
iHttpPort
The default port for HTTP connections. |
private static int |
iMinTokenLength
The minimum length for a token to be recorded as a regular expression. |
private java.io.DataInputStream |
input
Used to retrieve information from the browser. |
private static int |
iNumTries
The number of times to attempt to read an http response. |
private static int |
iPostRedirect
HTTP status code which indicates a POST redirect. |
private static int |
iRequestLineLimit
The number of lines to read from an incoming HTTP response for header info. |
private static int |
iReturnCodeIndex
The index to use when retrieving the HTTP status code. |
private static int |
iSleepTime
How long to wait between attempts to read an http response. |
private static int |
iSocketTimeout
The default timeout for http connections. |
private static int |
iSSLPort
The default port for SSL connections. |
private static int |
iTestCaseIndex
The starting index to use when parsing the test case name. |
private static int |
iURLStartIndex
The starting index to use when parsing URLs. |
private java.io.PrintStream |
output
Used to send information to the browser. |
private java.lang.String |
sConfigFile
The configuration file being written. |
private java.lang.String |
sData
The data sent with the URL accessed. |
private java.lang.String |
sExcludeFile
A file which contains a list of regexes to be excluded while recording. |
private java.lang.String |
sHost
The host being contacted for the HTTP request. |
private java.lang.String |
sMethod
The method associated with the URL accessed. |
private java.lang.String |
sParsedHeaders
Contains the HTTP header information. |
private java.lang.String |
sSeparator
The path separator for the OS on which this application is executing. |
private java.lang.String |
sTestcaseName
The name of the test case being accessed. |
private java.lang.String |
sURL
The URL being accessed. |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
proxyHandler()
The default constructor for the class, which takes no arguments. |
|
proxyHandler(java.io.InputStream in,
java.io.OutputStream out)
Get the input/output streams for the browser. |
Method Summary | |
private void |
buildRegexes(java.lang.String sHTMLContent)
Examine the content and build regular expressions which can be used to validate that content. |
private java.lang.String |
createGeneralDollarRegex(java.lang.String sStr)
Given something that might be a dollar amount, create a general regex that represents the value. |
private void |
customHandler()
The user calls certain URLs to start and stop testcases. |
private java.lang.String |
fixHeaders(java.lang.String sHeader)
Fix the HTTP headers so that microsoft webservers won't return errors. |
private java.lang.String |
fixRegex(java.lang.String sStr)
Fix special characters in the regex. |
private void |
flushImageToFile(java.lang.String sImageURL,
java.lang.String sLength)
Write image details to a file so they can later be added to the generate config file. |
private void |
flushToFile()
Write information retrieved to a config file that will processed later. |
private void |
flushURLToFile()
For a 302 response, we need to record the URL and data, but record regexes for the subsequent response. |
void |
generateConfigFile()
Based on the recorded data, and input from the browser, write the XML config file. |
boolean |
getEndProxy()
A boolean value which determines whether or not the proxy should exit and generate a config file. |
private void |
getExcludeList()
Read the file which contains regexes to exclude and store the regexes in an ArrayList. |
boolean |
getImageRecord()
Get the value which determines if images are being recorded. |
java.lang.String |
getParsedHeaders()
Return the headers that were set previously. |
boolean |
getPostRedirect()
Retrieve the value which indicates if a POST redirect request was encountered. |
private java.util.HashMap |
getPreferences()
Retrieve user preferences from a text file, if they exist. |
boolean |
getRecordOn()
Indicates whether a testcase is currently being recorded. |
private boolean |
getServerType()
Determine the server type. |
java.util.HashMap |
getServerTypes()
Return the server type information. |
boolean |
getSSL()
Indicates whether the user tried to access an SSL connection. |
java.lang.String |
getTestcaseName()
Return the currently assigned testcase name. |
java.lang.String |
getURL()
Return the last URL accessed. |
private boolean |
isExcluded(java.lang.String sStr)
Determines if the given String represents an excluded regular expression. |
private java.lang.String |
parseContent(java.lang.String sHTML)
Extract the HTML content from the data returned by the webserver. |
private void |
parseHeaders(java.lang.String sStr)
Parse the request headers into a hashmap. |
void |
run()
The method used to start this thread. |
private void |
sendRequest(byte[] b)
Send the browser request to the specified host, then read the response data. |
void |
setData(java.lang.String sVal)
Set the data that will be used to generate the config file. |
void |
setExcludeFile(java.lang.String sFile)
Set the name of the file which needs to be read to determine regexes that should NOT appear. |
void |
setImageRecord(boolean bVal)
Set the value which indicates if images are being recorded. |
void |
setParsedHeaders(java.lang.String sStr)
Set the HTTP headers. |
void |
setPostRedirect(boolean bVal)
Set the value which indicates if a POST redirect request was encountered. |
void |
setRecordOn(boolean bVal)
Sets the value to indicate whether a testcase is being recorded. |
void |
setSeparator(java.lang.String sVal)
Set the path separator so that the correct classpath can be displayed to the user. |
void |
setServerTypes(java.util.HashMap hData)
Set the server type information. |
void |
setTestcaseName(java.lang.String sStr)
Assign the current test case name a new value. |
private boolean |
validCharactersInRegex(java.lang.String sRegex)
Determine if the characters in the regex can be handled by the xml parser. |
private boolean |
validResponse(java.lang.String sCheck)
Determine if the response contains HTML content. |
private boolean |
validToken(java.lang.String sToken)
Determines if the given token is valid. |
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 |
private java.io.DataInputStream input
private java.io.PrintStream output
private java.util.HashMap hHeaders
private java.util.HashMap hServerTypes
private java.lang.String sHost
private java.lang.String sMethod
private java.lang.String sData
private java.lang.String sURL
private java.lang.String sParsedHeaders
private java.lang.String sTestcaseName
private java.lang.String sExcludeFile
private java.lang.String sConfigFile
private java.lang.String sSeparator
private java.util.ArrayList aRegexes
private java.util.ArrayList aExcludeList
private boolean bRecord
private boolean bEndProxy
private boolean bPostRedirect
private boolean bSSL
private boolean bImageRecord
private static final int iDefaultTimeout
private static final int iAllowedTries
private static final int iDefaultPort
private static final int iRequestLineLimit
private static final int iReturnCodeIndex
private static final int iHttpError
private static final int iPostRedirect
private static final int iMinTokenLength
private static final int iHttpPort
private static final int iSocketTimeout
private static final int iNumTries
private static final int iSleepTime
private static final int iURLStartIndex
private static final int iTestCaseIndex
private static final int iHeaderLimit
private static final int iSSLPort
Constructor Detail |
public proxyHandler(java.io.InputStream in, java.io.OutputStream out)
in
- the browser input streamout
- the browser output streampublic proxyHandler()
Method Detail |
public java.lang.String getTestcaseName()
public boolean getPostRedirect()
public void setPostRedirect(boolean bVal)
bVal
- the boolean value to use for assignmentpublic void setTestcaseName(java.lang.String sStr)
sStr
- the current test case namepublic boolean getEndProxy()
public boolean getRecordOn()
public boolean getSSL()
public boolean getImageRecord()
public void setImageRecord(boolean bVal)
bVal
- indicates whether images are being recordedpublic void setSeparator(java.lang.String sVal)
sVal
- the value for the path separatorpublic void setRecordOn(boolean bVal)
bVal
- the value for the parameterpublic void setExcludeFile(java.lang.String sFile)
sFile
- the name of the exclude filepublic void setData(java.lang.String sVal)
sVal
- the data used to generate the config filepublic java.lang.String getURL()
public java.util.HashMap getServerTypes()
public void setServerTypes(java.util.HashMap hData)
hData
- contains information on webserver typespublic java.lang.String getParsedHeaders()
public void setParsedHeaders(java.lang.String sStr)
sStr
- the HTTP header valuesprivate void parseHeaders(java.lang.String sStr)
sStr
- the header data represented as a Stringprivate boolean validResponse(java.lang.String sCheck)
sCheck
- the response data
private java.lang.String createGeneralDollarRegex(java.lang.String sStr)
sStr
- the value to examine
private java.lang.String fixRegex(java.lang.String sStr)
sStr
- the value to modify
private boolean validToken(java.lang.String sToken)
sToken
- the token to validate
private void buildRegexes(java.lang.String sHTMLContent)
sHTMLContent
- HTML content returned from the webserverprivate java.lang.String parseContent(java.lang.String sHTML)
sHTML
- the content returned by the webserver
private boolean getServerType()
private void sendRequest(byte[] b)
b
- an array of bytes to send to the webserverprivate void flushToFile()
private void flushURLToFile()
private void flushImageToFile(java.lang.String sImageURL, java.lang.String sLength)
sImageURL
- the URL of the image being accessedsLength
- the length of the image that is returned, in bytesprivate void getExcludeList()
private boolean isExcluded(java.lang.String sStr)
sStr
- the String to examine
private boolean validCharactersInRegex(java.lang.String sRegex)
sRegex
- the regular expression to be verified
public void generateConfigFile()
private java.util.HashMap getPreferences()
private void customHandler()
private java.lang.String fixHeaders(java.lang.String sHeader)
sHeader
- the header data from the browser
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |