类 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 anHtmlUnitDriver
that delegates toMockMvc
and optionally delegates to an actual connection for specific requests.By default, the driver will delegate to
MockMvc
to handle requests tolocalhost
and to aWebClient
to handle any other URL (i.e. to perform an actual HTTP request).- 从以下版本开始:
- 4.2
- 作者:
- Rob Winch, Sam Brannen
- 另请参阅:
mockMvcSetup(MockMvc)
,webAppContextSetup(WebApplicationContext)
,webAppContextSetup(WebApplicationContext, MockMvcConfigurer)
,javascriptEnabled(boolean)
,withDelegate(WebConnectionHtmlUnitDriver)
,build()
构造器概要
构造器 限定符 构造器 说明 protected
MockMvcHtmlUnitDriverBuilder(MockMvc mockMvc)
protected
MockMvcHtmlUnitDriverBuilder(WebApplicationContext context)
protected
MockMvcHtmlUnitDriverBuilder(WebApplicationContext context, MockMvcConfigurer configurer)
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 org.openqa.selenium.htmlunit.HtmlUnitDriver
build()
Build theHtmlUnitDriver
configured via this builder.MockMvcHtmlUnitDriverBuilder
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
.MockMvcHtmlUnitDriverBuilder
withDelegate(WebConnectionHtmlUnitDriver driver)
从类继承的方法 org.springframework.test.web.servlet.htmlunit.MockMvcWebConnectionBuilderSupport
alwaysUseMockMvc, contextPath, createConnection, createConnection, useMockMvc, useMockMvcForHosts
构造器详细资料
MockMvcHtmlUnitDriverBuilder
protected MockMvcHtmlUnitDriverBuilder(MockMvc mockMvc)
MockMvcHtmlUnitDriverBuilder
protected MockMvcHtmlUnitDriverBuilder(WebApplicationContext context)
MockMvcHtmlUnitDriverBuilder
protected MockMvcHtmlUnitDriverBuilder(WebApplicationContext context, MockMvcConfigurer configurer)
方法详细资料
mockMvcSetup
public static MockMvcHtmlUnitDriverBuilder mockMvcSetup(MockMvc mockMvc)
Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedMockMvc
instance.- 参数:
mockMvc
- theMockMvc
instance to use (nevernull
)- 返回:
- the MockMvcHtmlUnitDriverBuilder to customize
webAppContextSetup
public static MockMvcHtmlUnitDriverBuilder webAppContextSetup(WebApplicationContext context)
Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedWebApplicationContext
.- 参数:
context
- theWebApplicationContext
to create aMockMvc
instance from (nevernull
)- 返回:
- the MockMvcHtmlUnitDriverBuilder to customize
webAppContextSetup
public static MockMvcHtmlUnitDriverBuilder webAppContextSetup(WebApplicationContext context, MockMvcConfigurer configurer)
Create a newMockMvcHtmlUnitDriverBuilder
based on the suppliedWebApplicationContext
andMockMvcConfigurer
.- 参数:
context
- theWebApplicationContext
to create aMockMvc
instance from (nevernull
)configurer
- theMockMvcConfigurer
to apply (nevernull
)- 返回:
- the MockMvcHtmlUnitDriverBuilder to customize
javascriptEnabled
public MockMvcHtmlUnitDriverBuilder javascriptEnabled(boolean javascriptEnabled)
Specify whether JavaScript should be enabled.Default is
true
.- 参数:
javascriptEnabled
-true
if JavaScript should be enabled- 返回:
- this builder for further customizations
- 另请参阅:
build()
withDelegate
public MockMvcHtmlUnitDriverBuilder withDelegate(WebConnectionHtmlUnitDriver driver)
Supply theWebConnectionHtmlUnitDriver
that the driver built by this builder should delegate to when processing non-matching requests.- 参数:
driver
- theWebConnectionHtmlUnitDriver
to delegate to for requests that do not match (nevernull
)- 返回:
- this builder for further customizations
- 另请参阅:
build()
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.- 返回:
- the
HtmlUnitDriver
to use - 另请参阅:
withDelegate(WebConnectionHtmlUnitDriver)