类 MockMvcWebClientBuilder
- java.lang.Object
- org.springframework.test.web.servlet.htmlunit.MockMvcWebConnectionBuilderSupport<MockMvcWebClientBuilder>
- org.springframework.test.web.servlet.htmlunit.MockMvcWebClientBuilder
public class MockMvcWebClientBuilder extends MockMvcWebConnectionBuilderSupport<MockMvcWebClientBuilder>
MockMvcWebClientBuilder
simplifies the creation of an HtmlUnitWebClient
that delegates to aMockMvc
instance.The
MockMvc
instance used by the builder may be supplied directly or created transparently from aWebApplicationContext
.- 从以下版本开始:
- 4.2
- 作者:
- Rob Winch, Sam Brannen
- 另请参阅:
mockMvcSetup(MockMvc)
,webAppContextSetup(WebApplicationContext)
,webAppContextSetup(WebApplicationContext, MockMvcConfigurer)
,withDelegate(WebClient)
,build()
构造器概要
构造器 限定符 构造器 说明 protected
MockMvcWebClientBuilder(MockMvc mockMvc)
protected
MockMvcWebClientBuilder(WebApplicationContext context)
protected
MockMvcWebClientBuilder(WebApplicationContext context, MockMvcConfigurer configurer)
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 com.gargoylesoftware.htmlunit.WebClient
build()
Build theWebClient
configured via this builder.static MockMvcWebClientBuilder
mockMvcSetup(MockMvc mockMvc)
Create a newMockMvcWebClientBuilder
based on the suppliedMockMvc
instance.static MockMvcWebClientBuilder
webAppContextSetup(WebApplicationContext context)
Create a newMockMvcWebClientBuilder
based on the suppliedWebApplicationContext
.static MockMvcWebClientBuilder
webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer)
Create a newMockMvcWebClientBuilder
based on the suppliedWebApplicationContext
andMockMvcConfigurer
.MockMvcWebClientBuilder
withDelegate(com.gargoylesoftware.htmlunit.WebClient webClient)
从类继承的方法 org.springframework.test.web.servlet.htmlunit.MockMvcWebConnectionBuilderSupport
alwaysUseMockMvc, contextPath, createConnection, createConnection, useMockMvc, useMockMvcForHosts
构造器详细资料
MockMvcWebClientBuilder
protected MockMvcWebClientBuilder(MockMvc mockMvc)
MockMvcWebClientBuilder
protected MockMvcWebClientBuilder(WebApplicationContext context)
MockMvcWebClientBuilder
protected MockMvcWebClientBuilder(WebApplicationContext context, MockMvcConfigurer configurer)
方法详细资料
mockMvcSetup
public static MockMvcWebClientBuilder mockMvcSetup(MockMvc mockMvc)
Create a newMockMvcWebClientBuilder
based on the suppliedMockMvc
instance.- 参数:
mockMvc
- theMockMvc
instance to use; nevernull
- 返回:
- the MockMvcWebClientBuilder to customize
webAppContextSetup
public static MockMvcWebClientBuilder webAppContextSetup(WebApplicationContext context)
Create a newMockMvcWebClientBuilder
based on the suppliedWebApplicationContext
.- 参数:
context
- theWebApplicationContext
to create aMockMvc
instance from; nevernull
- 返回:
- the MockMvcWebClientBuilder to customize
webAppContextSetup
public static MockMvcWebClientBuilder webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer)
Create a newMockMvcWebClientBuilder
based on the suppliedWebApplicationContext
andMockMvcConfigurer
.- 参数:
context
- theWebApplicationContext
to create aMockMvc
instance from; nevernull
configurer
- theMockMvcConfigurer
to apply; nevernull
- 返回:
- the MockMvcWebClientBuilder to customize
withDelegate
public MockMvcWebClientBuilder withDelegate(com.gargoylesoftware.htmlunit.WebClient webClient)
Supply theWebClient
that the client built by this builder should delegate to when processing non-matching requests.- 参数:
webClient
- theWebClient
to delegate to for requests that do not match; nevernull
- 返回:
- this builder for further customization
- 另请参阅:
build()
build
public com.gargoylesoftware.htmlunit.WebClient build()
Build theWebClient
configured via this builder.The returned client will use the configured
MockMvc
instance for processing any matching requests and a delegateWebClient
for all other requests.If a delegate has been explicitly configured, it will be used; otherwise, a default
WebClient
will be configured as the delegate.- 返回:
- the
WebClient
to use - 另请参阅:
withDelegate(WebClient)