public class DebuggingWebConnection extends WebConnectionWrapper
final WebClient client = new WebClient(); final WebConnection connection = new DebuggingWebConnection(client.getWebConnection(), "myTest"); client.setWebConnection(connection);In this example an overview page will be generated under the name myTest/index.html in the temp directory and all received responses will be saved int the myTest folder.
Constructor and Description |
---|
DebuggingWebConnection(WebConnection webConnection,
String dirName)
Wraps a web connection to have a report generated of the received responses.
|
Modifier and Type | Method and Description |
---|---|
void |
addMark(String mark)
Adds a mark that will be visible in the HTML result page generated by this class.
|
WebResponse |
getResponse(WebRequestSettings settings)
Calls the wrapped webconnection and save the received response.
|
protected void |
saveResponse(WebResponse response,
WebRequestSettings settings)
Saves the response content in the temp dir and adds it to the summary page.
|
public DebuggingWebConnection(WebConnection webConnection, String dirName) throws IOException
webConnection
- the webConnection that do the real workdirName
- the name of the directory to create in the tmp folder to save received responses.
If this folder already exists, it will be deleted first.IOException
- in case of problems writing the filespublic WebResponse getResponse(WebRequestSettings settings) throws IOException
getResponse
in interface WebConnection
getResponse
in class WebConnectionWrapper
settings
- Settings to make the request withIOException
- if an IO error occurspublic void addMark(String mark) throws IOException
mark
- the textIOException
- if a problem occurs writing the fileprotected void saveResponse(WebResponse response, WebRequestSettings settings) throws IOException
response
- the response to savesettings
- the settings used to get the responseIOException
- if a problem occurs writing the fileCopyright © 2002–2014 Gargoyle Software Inc.. All rights reserved.