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 SummaryConstructorsModifierConstructorDescriptionprotectedMockMvcHtmlUnitDriverBuilder(MockMvc mockMvc) protectedprotectedMockMvcHtmlUnitDriverBuilder(WebApplicationContext context, MockMvcConfigurer configurer) 
- 
Method SummaryModifier and TypeMethodDescriptionorg.openqa.selenium.htmlunit.HtmlUnitDriverbuild()Build theHtmlUnitDriverconfigured via this builder.javascriptEnabled(boolean javascriptEnabled) Specify whether JavaScript should be enabled.static MockMvcHtmlUnitDriverBuildermockMvcSetup(MockMvc mockMvc) Create a newMockMvcHtmlUnitDriverBuilderbased on the suppliedMockMvcinstance.static MockMvcHtmlUnitDriverBuilderwebAppContextSetup(WebApplicationContext context) Create a newMockMvcHtmlUnitDriverBuilderbased on the suppliedWebApplicationContext.static MockMvcHtmlUnitDriverBuilderwebAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer) Create a newMockMvcHtmlUnitDriverBuilderbased on the suppliedWebApplicationContextandMockMvcConfigurer.Methods inherited from class MockMvcWebConnectionBuilderSupportalwaysUseMockMvc, contextPath, createConnection, useMockMvc, useMockMvcForHosts
- 
Constructor Details- 
MockMvcHtmlUnitDriverBuilder
- 
MockMvcHtmlUnitDriverBuilder
- 
MockMvcHtmlUnitDriverBuilder
 
- 
- 
Method Details- 
mockMvcSetupCreate a newMockMvcHtmlUnitDriverBuilderbased on the suppliedMockMvcinstance.- Parameters:
- mockMvc- the- MockMvcinstance to use (never- null)
- Returns:
- the MockMvcHtmlUnitDriverBuilder to customize
 
- 
webAppContextSetupCreate a newMockMvcHtmlUnitDriverBuilderbased on the suppliedWebApplicationContext.- Parameters:
- context- the- WebApplicationContextto create a- MockMvcinstance from (never- null)
- Returns:
- the MockMvcHtmlUnitDriverBuilder to customize
 
- 
webAppContextSetuppublic static MockMvcHtmlUnitDriverBuilder webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer) Create a newMockMvcHtmlUnitDriverBuilderbased on the suppliedWebApplicationContextandMockMvcConfigurer.- Parameters:
- context- the- WebApplicationContextto create a- MockMvcinstance from (never- null)
- configurer- the- MockMvcConfigurerto apply (never- null)
- Returns:
- the MockMvcHtmlUnitDriverBuilder to customize
 
- 
javascriptEnabledSpecify whether JavaScript should be enabled.Default is true.- Parameters:
- javascriptEnabled-- trueif JavaScript should be enabled
- Returns:
- this builder for further customizations
- See Also:
 
- 
withDelegateSupply theWebConnectionHtmlUnitDriverthat the driver built by this builder should delegate to when processing non-matching requests.- Parameters:
- driver- the- WebConnectionHtmlUnitDriverto delegate to for requests that do not match (never- null)
- Returns:
- this builder for further customizations
- See Also:
 
- 
buildpublic org.openqa.selenium.htmlunit.HtmlUnitDriver build()Build theHtmlUnitDriverconfigured via this builder.The returned driver will use the configured MockMvcinstance for processing any matching requests and a delegateHtmlUnitDriverfor all other requests.If a delegate has been explicitly configured, it will be used; otherwise, a default WebConnectionHtmlUnitDriverwith theBrowserVersionset toCHROMEwill be configured as the delegate.- Returns:
- the HtmlUnitDriverto use
- See Also:
 
 
-