public class MockWebConnection extends WebConnectionImpl
Constructor and Description |
---|
MockWebConnection(WebClient webClient)
Create an instance
|
Modifier and Type | Method and Description |
---|---|
Map |
getLastAdditionalHeaders()
Return the additional headers that were used in the in the last call
to
getResponse(WebRequestSettings) . |
SubmitMethod |
getLastMethod()
Return the method that was used in the last call to submitRequest()
|
List |
getLastParameters()
Return the parameters that were used in the last call to submitRequest()
|
WebRequestSettings |
getLastWebRequestSettings()
Return the
WebRequestSettings that was used in the in the last call
to getResponse(WebRequestSettings) . |
protected org.apache.commons.logging.Log |
getLog()
Return the log that is being used for all scripting objects
|
WebResponse |
getResponse(WebRequestSettings webRequestSettings)
Submit a request and retrieve a response
|
org.apache.commons.httpclient.HttpState |
getState()
Return the
HttpState |
void |
setDefaultResponse(byte[] content,
int statusCode,
String statusMessage,
String contentType)
Set the response that will be returned when a url is requested that does
not have a specific content set for it.
|
void |
setDefaultResponse(String content)
Set the response that will be returned when a url is requested that does
not have a specific content set for it.
|
void |
setDefaultResponse(String content,
int statusCode,
String statusMessage,
String contentType)
Set the response that will be returned when a url is requested that does
not have a specific content set for it.
|
void |
setResponse(URL url,
byte[] content,
int statusCode,
String statusMessage,
String contentType,
List responseHeaders)
Set the response that will be returned when the specified url is requested.
|
void |
setResponse(URL url,
String content)
Convenience method that is the same as calling
setResponse(URL,String,int,String,String,List) with a status
of "200 OK", a content type of "text/html" and no additional headers. |
void |
setResponse(URL url,
String content,
int statusCode,
String statusMessage,
String contentType,
List responseHeaders)
Set the response that will be returned when the specified url is requested.
|
void |
setResponse(URL url,
String content,
String contentType)
Convenience method that is the same as calling
setResponse(URL,String,int,String,String,List) with a status
of "200 OK" and no additional headers. |
void |
setResponseAsGenericHtml(URL url,
String title)
Specify a generic html page that will be returned when the given url is specified.
|
getWebClient
public MockWebConnection(WebClient webClient)
webClient
- The web clientprotected final org.apache.commons.logging.Log getLog()
public WebResponse getResponse(WebRequestSettings webRequestSettings) throws IOException
getResponse
in interface WebConnection
getResponse
in class WebConnectionImpl
webRequestSettings
- Settings to make the request withIOException
- (only for extending classes)public SubmitMethod getLastMethod()
public List getLastParameters()
public void setResponse(URL url, String content, int statusCode, String statusMessage, String contentType, List responseHeaders)
url
- The url that will return the given responsecontent
- The content to returnstatusCode
- The status code to returnstatusMessage
- The status message to returncontentType
- The content type to returnresponseHeaders
- A list of KeyValuePair
s that will be returned as
response headers.public void setResponse(URL url, byte[] content, int statusCode, String statusMessage, String contentType, List responseHeaders)
url
- The url that will return the given responsecontent
- The content to returnstatusCode
- The status code to returnstatusMessage
- The status message to returncontentType
- The content type to returnresponseHeaders
- A list of KeyValuePair
s that will be returned as
response headers.public void setResponse(URL url, String content)
setResponse(URL,String,int,String,String,List)
with a status
of "200 OK", a content type of "text/html" and no additional headers.url
- The url that will return the given responsecontent
- The content to returnpublic void setResponse(URL url, String content, String contentType)
setResponse(URL,String,int,String,String,List)
with a status
of "200 OK" and no additional headers.url
- The url that will return the given responsecontent
- The content to returncontentType
- The content type to returnpublic void setResponseAsGenericHtml(URL url, String title)
url
- The url that will return the given responsetitle
- The title of the pagepublic void setDefaultResponse(String content, int statusCode, String statusMessage, String contentType)
content
- The content to returnstatusCode
- The status code to returnstatusMessage
- The status message to returncontentType
- The content type to returnpublic void setDefaultResponse(byte[] content, int statusCode, String statusMessage, String contentType)
content
- The content to returnstatusCode
- The status code to returnstatusMessage
- The status message to returncontentType
- The content type to returnpublic void setDefaultResponse(String content)
content
- The content to returnpublic org.apache.commons.httpclient.HttpState getState()
HttpState
getState
in interface WebConnection
getState
in class WebConnectionImpl
public Map getLastAdditionalHeaders()
getResponse(WebRequestSettings)
.public WebRequestSettings getLastWebRequestSettings()
WebRequestSettings
that was used in the in the last call
to getResponse(WebRequestSettings)
.Copyright © 2002-2012 Gargoyle Software Inc.. All Rights Reserved.