类 MockMvcWebConnection
java.lang.Object
cn.taketoday.test.web.servlet.htmlunit.MockMvcWebConnection
- 所有已实现的接口:
AutoCloseable,org.htmlunit.WebConnection
MockMvcWebConnection enables MockMvc to transform a
WebRequest into a WebResponse.
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.0
- 作者:
- Rob Winch, Sam Brannen
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private final Stringprivate static final intprivate final MockMvcprivate final Map<String,MockHttpSession> private org.htmlunit.WebClient -
构造器概要
构造器构造器说明MockMvcWebConnection(MockMvc mockMvc, org.htmlunit.WebClient webClient) Create a new instance that assumes the context path of the application is""(i.e., the root context).MockMvcWebConnection(MockMvc mockMvc, org.htmlunit.WebClient webClient, String contextPath) Create a new instance with the specified context path. -
方法概要
修饰符和类型方法说明voidclose()private static org.htmlunit.util.CookiecreateCookie(jakarta.servlet.http.Cookie cookie) private MockHttpServletResponsegetResponse(RequestBuilder requestBuilder) org.htmlunit.WebResponsegetResponse(org.htmlunit.WebRequest webRequest) voidsetWebClient(org.htmlunit.WebClient webClient) private voidstoreCookies(org.htmlunit.WebRequest webRequest, jakarta.servlet.http.Cookie[] cookies) (专用程序包) static voidvalidateContextPath(String contextPath) Validate the suppliedcontextPath.
-
字段详细资料
-
sessions
-
mockMvc
-
contextPath
-
webClient
private org.htmlunit.WebClient webClient -
MAX_FORWARDS
private static final int MAX_FORWARDS- 另请参阅:
-
-
构造器详细资料
-
MockMvcWebConnection
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/thiswould use""as the context path.- 参数:
mockMvc- theMockMvcinstance to use; nevernullwebClient- theWebClientto use. nevernull
-
MockMvcWebConnection
public MockMvcWebConnection(MockMvc mockMvc, org.htmlunit.WebClient webClient, @Nullable String contextPath) Create a new instance with the specified context path.The path may be
nullin 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- theMockMvcinstance to use (nevernull)webClient- theWebClientto use (nevernull)contextPath- the contextPath to use
-
-
方法详细资料
-
validateContextPath
Validate the suppliedcontextPath.If the value is not
null, 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.- 参数:
contextPath- the path to validate
-
setWebClient
public void setWebClient(org.htmlunit.WebClient webClient) -
getResponse
- 指定者:
getResponse在接口中org.htmlunit.WebConnection- 抛出:
IOException
-
getResponse
- 抛出:
IOException
-
storeCookies
private void storeCookies(org.htmlunit.WebRequest webRequest, jakarta.servlet.http.Cookie[] cookies) -
createCookie
private static org.htmlunit.util.Cookie createCookie(jakarta.servlet.http.Cookie cookie) -
close
public void close()- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中org.htmlunit.WebConnection
-