类 MockMvcWebConnection
- java.lang.Object
- org.springframework.test.web.servlet.htmlunit.MockMvcWebConnection
- 所有已实现的接口:
com.gargoylesoftware.htmlunit.WebConnection
,AutoCloseable
public final class MockMvcWebConnection extends Object implements com.gargoylesoftware.htmlunit.WebConnection
MockMvcWebConnection
enablesMockMvc
to transform aWebRequest
into aWebResponse
.This is the core integration with HtmlUnit.
Example usage can be seen below.
WebClient webClient = new WebClient(); MockMvc mockMvc = ... MockMvcWebConnection webConnection = new MockMvcWebConnection(mockMvc, webClient); webClient.setWebConnection(webConnection); // Use webClient as normal ...
- 从以下版本开始:
- 4.2
- 作者:
- Rob Winch, Sam Brannen
- 另请参阅:
WebConnectionHtmlUnitDriver
构造器概要
构造器 构造器 说明 MockMvcWebConnection(MockMvc mockMvc)
MockMvcWebConnection(MockMvc mockMvc, com.gargoylesoftware.htmlunit.WebClient webClient)
Create a new instance that assumes the context path of the application is""
(i.e., the root context).MockMvcWebConnection(MockMvc mockMvc, com.gargoylesoftware.htmlunit.WebClient webClient, String contextPath)
Create a new instance with the specified context path.MockMvcWebConnection(MockMvc mockMvc, String contextPath)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
close()
com.gargoylesoftware.htmlunit.WebResponse
getResponse(com.gargoylesoftware.htmlunit.WebRequest webRequest)
void
setWebClient(com.gargoylesoftware.htmlunit.WebClient webClient)
构造器详细资料
MockMvcWebConnection
public MockMvcWebConnection(MockMvc mockMvc, com.gargoylesoftware.htmlunit.WebClient webClient)
Create a new instance that assumes the context path of the application is""
(i.e., the root context).For example, the URL
http://localhost/test/this
would use""
as the context path.- 参数:
mockMvc
- theMockMvc
instance to use; nevernull
webClient
- theWebClient
to use. nevernull
MockMvcWebConnection
public MockMvcWebConnection(MockMvc mockMvc, com.gargoylesoftware.htmlunit.WebClient webClient, String contextPath)
Create a new instance with the specified context path.The path may be
null
in which case the first path segment of the URL is turned into the contextPath. Otherwise it must conform toHttpServletRequest.getContextPath()
which states that it can be an empty string and otherwise must start with a "/" character and not end with a "/" character.- 参数:
mockMvc
- theMockMvc
instance to use (nevernull
)webClient
- theWebClient
to use (nevernull
)contextPath
- the contextPath to use
MockMvcWebConnection
@Deprecated public MockMvcWebConnection(MockMvc mockMvc)
Create a new instance that assumes the context path of the application is""
(i.e., the root context).For example, the URL
http://localhost/test/this
would use""
as the context path.- 参数:
mockMvc
- theMockMvc
instance to use; nevernull
MockMvcWebConnection
@Deprecated public MockMvcWebConnection(MockMvc mockMvc, String contextPath)
Create a new instance with the specified context path.The path may be
null
in which case the first path segment of the URL is turned into the contextPath. Otherwise it must conform toHttpServletRequest.getContextPath()
which states that it can be an empty string and otherwise must start with a "/" character and not end with a "/" character.- 参数:
mockMvc
- theMockMvc
instance to use; nevernull
contextPath
- the contextPath to use
方法详细资料
setWebClient
public void setWebClient(com.gargoylesoftware.htmlunit.WebClient webClient)
getResponse
public com.gargoylesoftware.htmlunit.WebResponse getResponse(com.gargoylesoftware.htmlunit.WebRequest webRequest) throws IOException
- 指定者:
getResponse
在接口中com.gargoylesoftware.htmlunit.WebConnection
- 抛出:
IOException
close
public void close()
- 指定者:
close
在接口中AutoCloseable