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 runnerfor a Servlet basedConfigurableWebApplicationContext.See
AbstractApplicationContextRunnerfor details.- Since:
- 2.0.0
Constructor Summary
Constructors Constructor Description WebApplicationContextRunner()Create a newWebApplicationContextRunnerinstance using anAnnotationConfigWebApplicationContextwith aMockServletContextas the underlying source.WebApplicationContextRunner(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory)Create a newWebApplicationContextRunnerinstance using the specifiedcontextFactoryas the underlying source.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected WebApplicationContextRunnernewInstance(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 specifiedcontextFactoryto set aMockServletContexton 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 newWebApplicationContextRunnerinstance using anAnnotationConfigWebApplicationContextwith aMockServletContextas the underlying source.- See Also:
withMockServletContext(Supplier)
WebApplicationContextRunner
public WebApplicationContextRunner(Supplier<org.springframework.web.context.ConfigurableWebApplicationContext> contextFactory)
Create a newWebApplicationContextRunnerinstance using the specifiedcontextFactoryas 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:
newInstancein 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 specifiedcontextFactoryto set aMockServletContexton each newly createdWebApplicationContext.- Parameters:
contextFactory- the context factory to decorate- Returns:
- an updated supplier that will set the
MockServletContext