|
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gargoylesoftware.htmlunit.WebConnectionImpl
com.gargoylesoftware.htmlunit.MockWebConnection
public class MockWebConnection
A fake WebConnection designed to mock out the actual http connections.
Constructor Summary | |
---|---|
MockWebConnection(WebClient webClient)
Create an instance |
Method Summary | |
---|---|
java.util.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() |
java.util.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) . |
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,
java.lang.String statusMessage,
java.lang.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(java.lang.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(java.lang.String content,
int statusCode,
java.lang.String statusMessage,
java.lang.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(java.net.URL url,
byte[] content,
int statusCode,
java.lang.String statusMessage,
java.lang.String contentType,
java.util.List responseHeaders)
Set the response that will be returned when the specified url is requested. |
void |
setResponse(java.net.URL url,
java.lang.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(java.net.URL url,
java.lang.String content,
int statusCode,
java.lang.String statusMessage,
java.lang.String contentType,
java.util.List responseHeaders)
Set the response that will be returned when the specified url is requested. |
void |
setResponse(java.net.URL url,
java.lang.String content,
java.lang.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(java.net.URL url,
java.lang.String title)
Specify a generic html page that will be returned when the given url is specified. |
Methods inherited from class com.gargoylesoftware.htmlunit.WebConnectionImpl |
---|
getWebClient |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockWebConnection(WebClient webClient)
webClient
- The web clientMethod Detail |
---|
public java.util.Map getLastAdditionalHeaders()
getResponse(WebRequestSettings)
.
public SubmitMethod getLastMethod()
public java.util.List getLastParameters()
public WebRequestSettings getLastWebRequestSettings()
WebRequestSettings
that was used in the in the last call
to getResponse(WebRequestSettings)
.
public WebResponse getResponse(WebRequestSettings webRequestSettings) throws java.io.IOException
getResponse
in interface WebConnection
getResponse
in class WebConnectionImpl
webRequestSettings
- Settings to make the request with
java.io.IOException
- (only for extending classes)public org.apache.commons.httpclient.HttpState getState()
HttpState
getState
in interface WebConnection
getState
in class WebConnectionImpl
public void setDefaultResponse(byte[] content, int statusCode, java.lang.String statusMessage, java.lang.String contentType)
content
- The content to returnstatusCode
- The status code to returnstatusMessage
- The status message to returncontentType
- The content type to returnpublic void setDefaultResponse(java.lang.String content)
content
- The content to returnpublic void setDefaultResponse(java.lang.String content, int statusCode, java.lang.String statusMessage, java.lang.String contentType)
content
- The content to returnstatusCode
- The status code to returnstatusMessage
- The status message to returncontentType
- The content type to returnpublic void setResponse(java.net.URL url, byte[] content, int statusCode, java.lang.String statusMessage, java.lang.String contentType, java.util.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(java.net.URL url, java.lang.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(java.net.URL url, java.lang.String content, int statusCode, java.lang.String statusMessage, java.lang.String contentType, java.util.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(java.net.URL url, java.lang.String content, java.lang.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(java.net.URL url, java.lang.String title)
url
- The url that will return the given responsetitle
- The title of the page
|
|||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |