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
ConstructorsConstructorDescriptionCreate a newWebApplicationContextRunnerinstance using anAnnotationConfigServletWebApplicationContextwith aMockServletContextas the underlying source.WebApplicationContextRunner(Supplier<ConfigurableWebApplicationContext> contextFactory) Create a newWebApplicationContextRunnerinstance using the specifiedcontextFactoryas the underlying source. -
Method Summary
Modifier and TypeMethodDescriptionwithMockServletContext(Supplier<ConfigurableWebApplicationContext> contextFactory) Decorate the specifiedcontextFactoryto set aMockServletContexton 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 newWebApplicationContextRunnerinstance using anAnnotationConfigServletWebApplicationContextwith aMockServletContextas the underlying source.- See Also:
-
WebApplicationContextRunner
Create a newWebApplicationContextRunnerinstance using the specifiedcontextFactoryas 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 specifiedcontextFactoryto set aMockServletContexton each newly createdWebApplicationContext.- Parameters:
contextFactory- the context factory to decorate- Returns:
- an updated supplier that will set the
MockServletContext
-