public class MockMvcHtmlUnitDriverBuilder extends MockMvcWebConnectionBuilderSupport<MockMvcHtmlUnitDriverBuilder>
MockMvcHtmlUnitDriverBuilder simplifies the building of an
HtmlUnitDriver that delegates to MockMvc and optionally
delegates to an actual connection for specific requests.
By default, the driver will delegate to MockMvc to handle
requests to localhost and to a WebClient to handle any
other URL (i.e. to perform an actual HTTP request).
mockMvcSetup(MockMvc),
webAppContextSetup(WebApplicationContext),
webAppContextSetup(WebApplicationContext, MockMvcConfigurer),
javascriptEnabled(boolean),
withDelegate(WebConnectionHtmlUnitDriver),
build()| Modifier | Constructor and Description |
|---|---|
protected |
MockMvcHtmlUnitDriverBuilder(MockMvc mockMvc) |
protected |
MockMvcHtmlUnitDriverBuilder(org.springframework.web.context.WebApplicationContext context) |
protected |
MockMvcHtmlUnitDriverBuilder(org.springframework.web.context.WebApplicationContext context,
MockMvcConfigurer configurer) |
| Modifier and Type | Method and Description |
|---|---|
org.openqa.selenium.htmlunit.HtmlUnitDriver |
build()
Build the
HtmlUnitDriver configured via this builder. |
MockMvcHtmlUnitDriverBuilder |
javascriptEnabled(boolean javascriptEnabled)
Specify whether JavaScript should be enabled.
|
static MockMvcHtmlUnitDriverBuilder |
mockMvcSetup(MockMvc mockMvc)
Create a new
MockMvcHtmlUnitDriverBuilder based on the supplied
MockMvc instance. |
static MockMvcHtmlUnitDriverBuilder |
webAppContextSetup(org.springframework.web.context.WebApplicationContext context)
Create a new
MockMvcHtmlUnitDriverBuilder based on the supplied
WebApplicationContext. |
static MockMvcHtmlUnitDriverBuilder |
webAppContextSetup(org.springframework.web.context.WebApplicationContext context,
MockMvcConfigurer configurer)
Create a new
MockMvcHtmlUnitDriverBuilder based on the supplied
WebApplicationContext and MockMvcConfigurer. |
MockMvcHtmlUnitDriverBuilder |
withDelegate(WebConnectionHtmlUnitDriver driver)
|
alwaysUseMockMvc, contextPath, createConnection, useMockMvc, useMockMvcForHostsprotected MockMvcHtmlUnitDriverBuilder(MockMvc mockMvc)
protected MockMvcHtmlUnitDriverBuilder(org.springframework.web.context.WebApplicationContext context)
protected MockMvcHtmlUnitDriverBuilder(org.springframework.web.context.WebApplicationContext context,
MockMvcConfigurer configurer)
public static MockMvcHtmlUnitDriverBuilder mockMvcSetup(MockMvc mockMvc)
MockMvcHtmlUnitDriverBuilder based on the supplied
MockMvc instance.mockMvc - the MockMvc instance to use (never null)public static MockMvcHtmlUnitDriverBuilder webAppContextSetup(org.springframework.web.context.WebApplicationContext context)
MockMvcHtmlUnitDriverBuilder based on the supplied
WebApplicationContext.context - the WebApplicationContext to create a MockMvc
instance from (never null)public static MockMvcHtmlUnitDriverBuilder webAppContextSetup(org.springframework.web.context.WebApplicationContext context, MockMvcConfigurer configurer)
MockMvcHtmlUnitDriverBuilder 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 MockMvcHtmlUnitDriverBuilder javascriptEnabled(boolean javascriptEnabled)
Default is true.
javascriptEnabled - true if JavaScript should be enabledbuild()public MockMvcHtmlUnitDriverBuilder withDelegate(WebConnectionHtmlUnitDriver driver)
WebConnectionHtmlUnitDriver that the driver
built by this builder should delegate to when
processing non-matching requests.driver - the WebConnectionHtmlUnitDriver to delegate to
for requests that do not match (never null)build()public org.openqa.selenium.htmlunit.HtmlUnitDriver build()
HtmlUnitDriver configured via this builder.
The returned driver will use the configured MockMvc instance
for processing any matching requests
and a delegate HtmlUnitDriver for all other requests.
If a delegate has been explicitly configured,
it will be used; otherwise, a default WebConnectionHtmlUnitDriver
with the BrowserVersion set to CHROME
will be configured as the delegate.
HtmlUnitDriver to usewithDelegate(WebConnectionHtmlUnitDriver)