|
||||||||||
| 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 | |
|---|---|
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 Log |
getLog()
Return the log that is being used for all scripting objects |
WebResponse |
getResponse(WebRequestSettings webRequestSettings)
Submit a request and retrieve a response |
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. |
| Methods inherited from class com.gargoylesoftware.htmlunit.WebConnectionImpl |
|---|
getWebClient |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MockWebConnection(WebClient webClient)
webClient - The web client| Method Detail |
|---|
protected final Log getLog()
public WebResponse getResponse(WebRequestSettings webRequestSettings)
throws IOException
getResponse in interface WebConnectiongetResponse in class WebConnectionImplwebRequestSettings - Settings to make the request with
IOException - (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 KeyValuePairs 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 KeyValuePairs 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 return
public 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 return
public void setResponseAsGenericHtml(URL url,
String title)
url - The url that will return the given responsetitle - The title of the page
public 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 return
public 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 HttpState getState()
HttpState
getState in interface WebConnectiongetState in class WebConnectionImplpublic Map getLastAdditionalHeaders()
getResponse(WebRequestSettings).
public WebRequestSettings getLastWebRequestSettings()
WebRequestSettings that was used in the in the last call
to getResponse(WebRequestSettings).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||