public final class MockMvcWebConnection
extends java.lang.Object
implements com.gargoylesoftware.htmlunit.WebConnection
Allows MockMvc
to transform a WebRequest
into a WebResponse
. This is the core integration
with HTML Unit.
Example usage can be seen below:
MockMvc mockMvc = ... MockMvcWebConnection webConnection = new MockMvcWebConnection(mockMvc); WebClient webClient = new WebClient(); webClient.setWebConnection(webConnection); ... use webClient as normal ...
WebConnectionHtmlUnitDriver
Constructor and Description |
---|
MockMvcWebConnection(org.springframework.test.web.servlet.MockMvc mockMvc)
Creates a new instance that assumes the context root of the application is "".
|
MockMvcWebConnection(org.springframework.test.web.servlet.MockMvc mockMvc,
java.lang.String contextPath)
Creates a new instance with a specified context root.
|
Modifier and Type | Method and Description |
---|---|
com.gargoylesoftware.htmlunit.WebResponse |
getResponse(com.gargoylesoftware.htmlunit.WebRequest webRequest) |
public MockMvcWebConnection(org.springframework.test.web.servlet.MockMvc mockMvc)
mockMvc
- the MockMvc instance to usepublic MockMvcWebConnection(org.springframework.test.web.servlet.MockMvc mockMvc, java.lang.String contextPath)
mockMvc
- the MockMvc instance to usecontextPath
- the contextPath to use. The value may be null in which case the first path segment of the URL is turned
into the contextPath. Otherwise it must conform to HttpServletRequest.getContextPath()
which states it
can be empty string or it must start with a "/" and not end in a "/".