|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
avignon.handlers.TestHttpServer
The TestHttpServer class is used to support browser unit tests. It runs on port 7001 and responds to requests of the form
GET /PathToPage HTTP/1.1 and POST /PathToPage HTTP/1.1 for file uploads only.
| Field Summary |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
TestHttpServer()
Constructs an instance of the server and starts listening on port 7001. |
|
TestHttpServer(int port)
Starts the server on the specified port. |
|
| Method Summary | |
void |
expectFileUpload(java.lang.String page,
java.lang.String response,
java.io.ByteArrayOutputStream buffer)
Prepares the test server to accept an uploaded file. |
java.lang.String |
getLastRequestText()
Determines the text of the last HTTP request made. |
java.lang.Integer |
getListeningPort()
Determine the port currently being used by the server. |
byte[] |
getPageForRequest(java.io.InputStream s)
Determines the response text that will be used for a particular request. |
void |
run()
HTTP server thread run method. |
void |
setDebuggingFlag(boolean debug)
Deprecated. Duplicates setDebugServer. |
void |
setDebugServer(boolean debugServer)
Determines whether debugging information should be sent to the standard output or not. |
void |
setResponseDelay(int milliseconds)
Sets the amount of time to wait before responding to a request. |
void |
shuntBinaryResponse(java.lang.String request,
java.lang.String contentType,
byte[] responseData)
Adds a response containing binary data to the server. |
void |
shuntServerResponse(java.lang.String getPage,
java.io.File pageFile)
Sets the text to return when a specific page is requested. |
void |
shuntServerResponse(java.lang.String getPage,
java.lang.String pageText)
Sets the text to return when a specific page is requested. |
void |
stopListening()
Closes the server socket. |
| 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 |
| Constructor Detail |
public TestHttpServer()
public TestHttpServer(int port)
port - Port on which to listen. Make sure that it is not being used by any other servers.| Method Detail |
public void shuntBinaryResponse(java.lang.String request,
java.lang.String contentType,
byte[] responseData)
request - Name of the GET page to be shuntedcontentType - Type of content to be returned.responseData - Actual data to send to the client when the page is requested. HTTP headers will be added.public java.lang.Integer getListeningPort()
public void setResponseDelay(int milliseconds)
milliseconds - Time in milliseconds to wait before responding to a request.
public void shuntServerResponse(java.lang.String getPage,
java.lang.String pageText)
getPage - Name of the page to be shunted.pageText - Text to be returned when a request for GET /getPage HTTP/1.1 is made.
public void shuntServerResponse(java.lang.String getPage,
java.io.File pageFile)
throws java.io.IOException
getPage - Name of the page to be shunted.pageFile - File containing text to be return when shunted page is requested.
java.io.IOException - If there is a problem reading the file.public void setDebuggingFlag(boolean debug)
debug - True to cause debugging output to be written to the standard output.public java.lang.String getLastRequestText()
public void run()
public byte[] getPageForRequest(java.io.InputStream s)
throws java.io.IOException
s - The InputStream for the HTTP request. Currently GET requests are supported and POST requests are supported for file upload only.
java.io.IOException - Thrown if anything happens reading the stream.
public void stopListening()
throws java.io.IOException
java.io.IOException - If any errors occur closing the socket.public void setDebugServer(boolean debugServer)
debugServer - True if debugging information should be sent to the standard output or not.
public void expectFileUpload(java.lang.String page,
java.lang.String response,
java.io.ByteArrayOutputStream buffer)
page - Name of the page that will be POSTed to.response - The text of the response to return to the client.buffer - Place to store the uploaded file for later testing.
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||