Class WebApplicationContextRunner
java.lang.Object
org.springframework.boot.test.context.runner.AbstractApplicationContextRunner<WebApplicationContextRunner,ConfigurableWebApplicationContext,AssertableWebApplicationContext>
org.springframework.boot.test.context.runner.WebApplicationContextRunner
public final class WebApplicationContextRunner
extends AbstractApplicationContextRunner<WebApplicationContextRunner,ConfigurableWebApplicationContext,AssertableWebApplicationContext>
An
ApplicationContext runner
for a Servlet
based ConfigurableWebApplicationContext
.
See AbstractApplicationContextRunner
for details.
- Since:
- 2.0.0
- Author:
- Andy Wilkinson, Stephane Nicoll, Phillip Webb
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.boot.test.context.runner.AbstractApplicationContextRunner
AbstractApplicationContextRunner.BeanRegistration<T>, AbstractApplicationContextRunner.RunnerConfiguration<C extends ConfigurableApplicationContext>
-
Constructor Summary
ConstructorDescriptionCreate a newWebApplicationContextRunner
instance using anAnnotationConfigServletWebApplicationContext
with aMockServletContext
as the underlying source.WebApplicationContextRunner
(Supplier<ConfigurableWebApplicationContext> contextFactory) Create a newWebApplicationContextRunner
instance using the specifiedcontextFactory
as the underlying source. -
Method Summary
Modifier and TypeMethodDescriptionwithMockServletContext
(Supplier<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
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<ConfigurableWebApplicationContext> withMockServletContext(Supplier<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
-