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>
An
ApplicationContext runner
for a Servlet
based ConfigurableWebApplicationContext
.
See AbstractApplicationContextRunner
for details.
- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.boot.test.context.runner.AbstractApplicationContextRunner
AbstractApplicationContextRunner.BeanRegistration<T>, AbstractApplicationContextRunner.RunnerConfiguration<C extends org.springframework.context.ConfigurableApplicationContext>
-
Constructor Summary
ConstructorDescriptionCreate a newWebApplicationContextRunner
instance using anAnnotationConfigServletWebApplicationContext
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
Modifier and TypeMethodDescriptionstatic 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
prepare, run, with, withAllowBeanDefinitionOverriding, withAllowCircularReferences, withBean, withBean, withBean, withBean, withClassLoader, withConfiguration, withInitializer, withParent, withPropertyValues, withSystemProperties, withUserConfiguration
-
Constructor Details
-
WebApplicationContextRunner
public WebApplicationContextRunner()Create a newWebApplicationContextRunner
instance using anAnnotationConfigServletWebApplicationContext
with aMockServletContext
as the underlying source.- See Also:
-
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 Details
-
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
-