public class MockMvcWebClientBuilder extends MockMvcWebConnectionBuilderSupport<MockMvcWebClientBuilder>
MockMvcWebClientBuilder
simplifies the creation of an HtmlUnit
WebClient
that delegates to a MockMvc
instance.
The MockMvc
instance used by the builder may be
supplied directly or created transparently
from a WebApplicationContext
.
mockMvcSetup(MockMvc)
,
webAppContextSetup(WebApplicationContext)
,
webAppContextSetup(WebApplicationContext, MockMvcConfigurer)
,
withDelegate(WebClient)
,
build()
Modifier | Constructor and Description |
---|---|
protected |
MockMvcWebClientBuilder(MockMvc mockMvc) |
protected |
MockMvcWebClientBuilder(WebApplicationContext context) |
protected |
MockMvcWebClientBuilder(WebApplicationContext context,
MockMvcConfigurer configurer) |
Modifier and Type | Method and Description |
---|---|
com.gargoylesoftware.htmlunit.WebClient |
build()
Build the
WebClient configured via this builder. |
static MockMvcWebClientBuilder |
mockMvcSetup(MockMvc mockMvc)
Create a new
MockMvcWebClientBuilder based on the supplied
MockMvc instance. |
static MockMvcWebClientBuilder |
webAppContextSetup(WebApplicationContext context)
Create a new
MockMvcWebClientBuilder based on the supplied
WebApplicationContext . |
static MockMvcWebClientBuilder |
webAppContextSetup(WebApplicationContext context,
MockMvcConfigurer configurer)
Create a new
MockMvcWebClientBuilder based on the supplied
WebApplicationContext and MockMvcConfigurer . |
MockMvcWebClientBuilder |
withDelegate(com.gargoylesoftware.htmlunit.WebClient webClient)
|
alwaysUseMockMvc, contextPath, createConnection, useMockMvc, useMockMvcForHosts
protected MockMvcWebClientBuilder(MockMvc mockMvc)
protected MockMvcWebClientBuilder(WebApplicationContext context)
protected MockMvcWebClientBuilder(WebApplicationContext context, MockMvcConfigurer configurer)
public static MockMvcWebClientBuilder mockMvcSetup(MockMvc mockMvc)
MockMvcWebClientBuilder
based on the supplied
MockMvc
instance.mockMvc
- the MockMvc
instance to use; never null
public static MockMvcWebClientBuilder webAppContextSetup(WebApplicationContext context)
MockMvcWebClientBuilder
based on the supplied
WebApplicationContext
.context
- the WebApplicationContext
to create a MockMvc
instance from; never null
public static MockMvcWebClientBuilder webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer)
MockMvcWebClientBuilder
based on the supplied
WebApplicationContext
and MockMvcConfigurer
.context
- the WebApplicationContext
to create a MockMvc
instance from; never null
configurer
- the MockMvcConfigurer
to apply; never null
public MockMvcWebClientBuilder withDelegate(com.gargoylesoftware.htmlunit.WebClient webClient)
WebClient
that the client built
by this builder should delegate to when processing
non-matching requests.webClient
- the WebClient
to delegate to for requests
that do not match; never null
build()
public com.gargoylesoftware.htmlunit.WebClient build()
WebClient
configured via this builder.
The returned client will use the configured MockMvc
instance
for processing any matching requests
and a delegate WebClient
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.
WebClient
to usewithDelegate(WebClient)