Class MockMvcHtmlUnitDriverBuilder
java.lang.Object
org.springframework.test.web.servlet.htmlunit.MockMvcWebConnectionBuilderSupport<MockMvcHtmlUnitDriverBuilder>
org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDriverBuilder
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).
- Since:
- 4.2
- Author:
- Rob Winch, Sam Brannen
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
MockMvcHtmlUnitDriverBuilder
(MockMvc mockMvc) protected
protected
MockMvcHtmlUnitDriverBuilder
(WebApplicationContext context, MockMvcConfigurer configurer) -
Method Summary
Modifier and TypeMethodDescriptionorg.openqa.selenium.htmlunit.HtmlUnitDriver
build()
Build theHtmlUnitDriver
configured via this builder.javascriptEnabled
(boolean javascriptEnabled) Specify whether JavaScript should be enabled.static MockMvcHtmlUnitDriverBuilder
mockMvcSetup
(MockMvc mockMvc) Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedMockMvc
instance.static MockMvcHtmlUnitDriverBuilder
webAppContextSetup
(WebApplicationContext context) Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedWebApplicationContext
.static MockMvcHtmlUnitDriverBuilder
webAppContextSetup
(WebApplicationContext context, MockMvcConfigurer configurer) Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedWebApplicationContext
andMockMvcConfigurer
.Methods inherited from class org.springframework.test.web.servlet.htmlunit.MockMvcWebConnectionBuilderSupport
alwaysUseMockMvc, contextPath, createConnection, useMockMvc, useMockMvcForHosts
-
Constructor Details
-
MockMvcHtmlUnitDriverBuilder
-
MockMvcHtmlUnitDriverBuilder
-
MockMvcHtmlUnitDriverBuilder
-
-
Method Details
-
mockMvcSetup
Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedMockMvc
instance.- Parameters:
mockMvc
- theMockMvc
instance to use (nevernull
)- Returns:
- the MockMvcHtmlUnitDriverBuilder to customize
-
webAppContextSetup
Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedWebApplicationContext
.- Parameters:
context
- theWebApplicationContext
to create aMockMvc
instance from (nevernull
)- Returns:
- the MockMvcHtmlUnitDriverBuilder to customize
-
webAppContextSetup
public static MockMvcHtmlUnitDriverBuilder webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer) Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedWebApplicationContext
andMockMvcConfigurer
.- Parameters:
context
- theWebApplicationContext
to create aMockMvc
instance from (nevernull
)configurer
- theMockMvcConfigurer
to apply (nevernull
)- Returns:
- the MockMvcHtmlUnitDriverBuilder to customize
-
javascriptEnabled
Specify whether JavaScript should be enabled.Default is
true
.- Parameters:
javascriptEnabled
-true
if JavaScript should be enabled- Returns:
- this builder for further customizations
- See Also:
-
withDelegate
Supply theWebConnectionHtmlUnitDriver
that the driver built by this builder should delegate to when processing non-matching requests.- Parameters:
driver
- theWebConnectionHtmlUnitDriver
to delegate to for requests that do not match (nevernull
)- Returns:
- this builder for further customizations
- See Also:
-
build
public org.openqa.selenium.htmlunit.HtmlUnitDriver build()Build theHtmlUnitDriver
configured via this builder.The returned driver will use the configured
MockMvc
instance for processing any matching requests and a delegateHtmlUnitDriver
for all other requests.If a delegate has been explicitly configured, it will be used; otherwise, a default
WebConnectionHtmlUnitDriver
with theBrowserVersion
set toCHROME
will be configured as the delegate.- Returns:
- the
HtmlUnitDriver
to use - See Also:
-