Class 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.- Since:
- 2.0.0
Constructor Summary
Constructors Constructor Description 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.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
.Methods inherited from class org.springframework.boot.test.context.runner.AbstractApplicationContextRunner
run, with, withClassLoader, withConfiguration, withInitializer, withParent, withPropertyValues, withSystemProperties, withUserConfiguration
Constructor Detail
WebApplicationContextRunner
public WebApplicationContextRunner()
Create a newWebApplicationContextRunner
instance using anAnnotationConfigWebApplicationContext
with aMockServletContext
as the underlying source.- See Also:
withMockServletContext(Supplier)
WebApplicationContextRunner
public WebApplicationContextRunner(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory)
Create a newWebApplicationContextRunner
instance using the specifiedcontextFactory
as the underlying source.- Parameters:
contextFactory
- a supplier that returns a new instance on each call
Method Detail
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)
- Specified by:
newInstance
in classAbstractApplicationContextRunner<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
.- Parameters:
contextFactory
- the context factory to decorate- Returns:
- an updated supplier that will set the
MockServletContext