类 MockMvcWebConnectionBuilderSupport<T extends MockMvcWebConnectionBuilderSupport<T>>
java.lang.Object
cn.taketoday.test.web.servlet.htmlunit.MockMvcWebConnectionBuilderSupport<T>
- 类型参数:
T- a self reference to the builder type
public abstract class MockMvcWebConnectionBuilderSupport<T extends MockMvcWebConnectionBuilderSupport<T>>
extends Object
Support class that simplifies the creation of a
WebConnection that
uses MockMvc and optionally delegates to a real WebConnection
for specific requests.
The default is to use MockMvc for requests to localhost
and otherwise use a real WebConnection.
- 从以下版本开始:
- 4.0
- 作者:
- Rob Winch, Sam Brannen
-
字段概要
字段修饰符和类型字段说明private booleanprivate Stringprivate final MockMvcprivate final List<WebRequestMatcher> -
构造器概要
构造器限定符构造器说明protectedCreate a new instance using the suppliedMockMvcinstance.protectedMockMvcWebConnectionBuilderSupport(cn.taketoday.web.servlet.WebApplicationContext context) Create a new instance using the suppliedWebApplicationContext.protectedMockMvcWebConnectionBuilderSupport(cn.taketoday.web.servlet.WebApplicationContext context, MockMvcConfigurer configurer) Create a new instance using the suppliedWebApplicationContextandMockMvcConfigurer. -
方法概要
修饰符和类型方法说明Specify thatMockMvcshould always be used regardless of what the request looks like.contextPath(String contextPath) Set the context path to use.protected final org.htmlunit.WebConnectioncreateConnection(org.htmlunit.WebClient webClient) Create a newWebConnectionthat will use aMockMvcinstance if one of the specifiedWebRequestMatcherinstances matches.private org.htmlunit.WebConnectioncreateConnection(org.htmlunit.WebClient webClient, org.htmlunit.WebConnection defaultConnection) useMockMvc(WebRequestMatcher... matchers) Add additionalWebRequestMatcherinstances that will ensure thatMockMvcis used to process the request, if such a matcher matches against the web request.useMockMvcForHosts(String... hosts) Add additionalWebRequestMatcherinstances that returntrueif a supplied host matches — for example,"example.com"or"example.com:8080".
-
字段详细资料
-
mockMvc
-
requestMatchers
-
contextPath
-
alwaysUseMockMvc
private boolean alwaysUseMockMvc
-
-
构造器详细资料
-
MockMvcWebConnectionBuilderSupport
Create a new instance using the suppliedMockMvcinstance.- 参数:
mockMvc- theMockMvcinstance to use; nevernull
-
MockMvcWebConnectionBuilderSupport
protected MockMvcWebConnectionBuilderSupport(cn.taketoday.web.servlet.WebApplicationContext context) Create a new instance using the suppliedWebApplicationContext.- 参数:
context- theWebApplicationContextto create aMockMvcinstance from; nevernull
-
MockMvcWebConnectionBuilderSupport
protected MockMvcWebConnectionBuilderSupport(cn.taketoday.web.servlet.WebApplicationContext context, MockMvcConfigurer configurer) Create a new instance using the suppliedWebApplicationContextandMockMvcConfigurer.- 参数:
context- theWebApplicationContextto create aMockMvcinstance from; nevernullconfigurer- the MockMvcConfigurer to apply; nevernull
-
-
方法详细资料
-
contextPath
Set the context path to use.If the supplied value is
nullor empty, the first path segment of the request URL is assumed to be the context path.Default is
"".- 参数:
contextPath- the context path to use- 返回:
- this builder for further customization
-
alwaysUseMockMvc
Specify thatMockMvcshould always be used regardless of what the request looks like.- 返回:
- this builder for further customization
-
useMockMvc
Add additionalWebRequestMatcherinstances that will ensure thatMockMvcis used to process the request, if such a matcher matches against the web request.- 参数:
matchers- additionalWebRequestMatcherinstances- 返回:
- this builder for further customization
-
useMockMvcForHosts
Add additionalWebRequestMatcherinstances that returntrueif a supplied host matches — for example,"example.com"or"example.com:8080".- 参数:
hosts- additional hosts that ensureMockMvcgets invoked- 返回:
- this builder for further customization
-
createConnection
protected final org.htmlunit.WebConnection createConnection(org.htmlunit.WebClient webClient) Create a newWebConnectionthat will use aMockMvcinstance if one of the specifiedWebRequestMatcherinstances matches.- 参数:
webClient- the WebClient to use if none of the specifiedWebRequestMatcherinstances matches (nevernull)- 返回:
- a new
WebConnectionthat will use aMockMvcinstance if one of the specifiedWebRequestMatchermatches - 另请参阅:
-
createConnection
private org.htmlunit.WebConnection createConnection(org.htmlunit.WebClient webClient, org.htmlunit.WebConnection defaultConnection)
-