类 WebApplicationContextRunner
- java.lang.Object
- org.springframework.boot.test.context.runner.AbstractApplicationContextRunner<WebApplicationContextRunner,org.springframework.web.context.ConfigurableWebApplicationContext,AssertableWebApplicationContext>
- org.springframework.boot.test.context.runner.WebApplicationContextRunner
public final class WebApplicationContextRunner extends AbstractApplicationContextRunner<WebApplicationContextRunner,org.springframework.web.context.ConfigurableWebApplicationContext,AssertableWebApplicationContext>
AnApplicationContext runner
for a Servlet basedConfigurableWebApplicationContext
.See
AbstractApplicationContextRunner
for details.- 从以下版本开始:
- 2.0.0
构造器概要
构造器 构造器 说明 WebApplicationContextRunner()
Create a newWebApplicationContextRunner
instance using anAnnotationConfigWebApplicationContext
with aMockServletContext
as the underlying source.WebApplicationContextRunner(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory)
Create a newWebApplicationContextRunner
instance using the specifiedcontextFactory
as the underlying source.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 protected WebApplicationContextRunner
newInstance(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory, List<org.springframework.context.ApplicationContextInitializer<? super org.springframework.web.context.ConfigurableWebApplicationContext>> initializers, TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, org.springframework.context.ApplicationContext parent, List<org.springframework.boot.context.annotation.Configurations> configurations)
static Supplier<org.springframework.web.context.ConfigurableWebApplicationContext>
withMockServletContext(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory)
Decorate the specifiedcontextFactory
to set aMockServletContext
on each newly createdWebApplicationContext
.从类继承的方法 org.springframework.boot.test.context.runner.AbstractApplicationContextRunner
run, with, withClassLoader, withConfiguration, withInitializer, withParent, withPropertyValues, withSystemProperties, withUserConfiguration
构造器详细资料
WebApplicationContextRunner
public WebApplicationContextRunner()
Create a newWebApplicationContextRunner
instance using anAnnotationConfigWebApplicationContext
with aMockServletContext
as the underlying source.
WebApplicationContextRunner
public WebApplicationContextRunner(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory)
Create a newWebApplicationContextRunner
instance using the specifiedcontextFactory
as the underlying source.- 参数:
contextFactory
- a supplier that returns a new instance on each call
方法详细资料
newInstance
protected WebApplicationContextRunner newInstance(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory, List<org.springframework.context.ApplicationContextInitializer<? super org.springframework.web.context.ConfigurableWebApplicationContext>> initializers, TestPropertyValues environmentProperties, TestPropertyValues systemProperties, ClassLoader classLoader, org.springframework.context.ApplicationContext parent, List<org.springframework.boot.context.annotation.Configurations> configurations)
- 指定者:
newInstance
在类中AbstractApplicationContextRunner<WebApplicationContextRunner,org.springframework.web.context.ConfigurableWebApplicationContext,AssertableWebApplicationContext>
withMockServletContext
public static Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> withMockServletContext(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory)
Decorate the specifiedcontextFactory
to set aMockServletContext
on each newly createdWebApplicationContext
.- 参数:
contextFactory
- the context factory to decorate- 返回:
- an updated supplier that will set the
MockServletContext