public class SpringBootTestContextBootstrapper
extends org.springframework.test.context.support.DefaultTestContextBootstrapper
TestContextBootstrapper for Spring Boot. Provides support for
@SpringBootTest and may also be used directly or subclassed.
Provides the following features over and above DefaultTestContextBootstrapper:
SpringBootContextLoader as the
default context loader.@SpringBootConfiguration when required.Environment getProperties(Class) to be defined.webEnvironment modes.SpringBootTest,
TestConfiguration| Constructor and Description |
|---|
SpringBootTestContextBootstrapper() |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.test.context.TestContext |
buildTestContext() |
protected org.springframework.test.context.MergedContextConfiguration |
createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig,
java.lang.Class<?>[] classes)
Create a new
MergedContextConfiguration with different classes. |
protected org.springframework.test.context.MergedContextConfiguration |
createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig,
java.lang.Class<?>[] classes,
java.lang.String[] propertySourceProperties)
Create a new
MergedContextConfiguration with different classes and
properties. |
protected java.lang.String |
determineResourceBasePath(org.springframework.test.context.MergedContextConfiguration configuration)
Determines the resource base path for web applications using the value of
@WebAppConfiguration, if any, on the test class of the
given configuration. |
protected SpringBootTest |
getAnnotation(java.lang.Class<?> testClass) |
protected java.lang.Class<?>[] |
getClasses(java.lang.Class<?> testClass) |
protected java.lang.Class<? extends org.springframework.test.context.ContextLoader> |
getDefaultContextLoaderClass(java.lang.Class<?> testClass) |
protected java.util.Set<java.lang.Class<? extends org.springframework.test.context.TestExecutionListener>> |
getDefaultTestExecutionListenerClasses() |
protected java.lang.String |
getDifferentiatorPropertySourceProperty()
Return a "differentiator" property to ensure that there is something to
differentiate regular tests and bootstrapped tests.
|
protected java.lang.Class<?>[] |
getOrFindConfigurationClasses(org.springframework.test.context.MergedContextConfiguration mergedConfig) |
protected java.lang.String[] |
getProperties(java.lang.Class<?> testClass) |
protected SpringBootTest.WebEnvironment |
getWebEnvironment(java.lang.Class<?> testClass)
Return the
SpringBootTest.WebEnvironment type for this test or null if undefined. |
protected org.springframework.test.context.MergedContextConfiguration |
processMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration mergedConfig) |
protected void |
processPropertySourceProperties(org.springframework.test.context.MergedContextConfiguration mergedConfig,
java.util.List<java.lang.String> propertySourceProperties)
Post process the property source properties, adding or removing elements as
required.
|
protected org.springframework.test.context.ContextLoader |
resolveContextLoader(java.lang.Class<?> testClass,
java.util.List<org.springframework.test.context.ContextConfigurationAttributes> configAttributesList) |
protected void |
verifyConfiguration(java.lang.Class<?> testClass) |
buildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getDefaultTestExecutionListenerClassNames, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContextpublic org.springframework.test.context.TestContext buildTestContext()
buildTestContext in interface org.springframework.test.context.TestContextBootstrapperbuildTestContext in class org.springframework.test.context.support.AbstractTestContextBootstrapperprotected java.util.Set<java.lang.Class<? extends org.springframework.test.context.TestExecutionListener>> getDefaultTestExecutionListenerClasses()
getDefaultTestExecutionListenerClasses in class org.springframework.test.context.support.AbstractTestContextBootstrapperprotected org.springframework.test.context.ContextLoader resolveContextLoader(java.lang.Class<?> testClass,
java.util.List<org.springframework.test.context.ContextConfigurationAttributes> configAttributesList)
resolveContextLoader in class org.springframework.test.context.support.AbstractTestContextBootstrapperprotected java.lang.Class<? extends org.springframework.test.context.ContextLoader> getDefaultContextLoaderClass(java.lang.Class<?> testClass)
getDefaultContextLoaderClass in class org.springframework.test.context.support.DefaultTestContextBootstrapperprotected org.springframework.test.context.MergedContextConfiguration processMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration mergedConfig)
processMergedContextConfiguration in class org.springframework.test.context.support.AbstractTestContextBootstrapperprotected java.lang.String determineResourceBasePath(org.springframework.test.context.MergedContextConfiguration configuration)
@WebAppConfiguration, if any, on the test class of the
given configuration. Defaults to src/main/webapp in its absence.configuration - the configuration to examineprotected java.lang.Class<?>[] getOrFindConfigurationClasses(org.springframework.test.context.MergedContextConfiguration mergedConfig)
protected java.lang.String getDifferentiatorPropertySourceProperty()
nullprotected void processPropertySourceProperties(org.springframework.test.context.MergedContextConfiguration mergedConfig,
java.util.List<java.lang.String> propertySourceProperties)
mergedConfig - the merged context configurationpropertySourceProperties - the property source properties to processprotected SpringBootTest.WebEnvironment getWebEnvironment(java.lang.Class<?> testClass)
SpringBootTest.WebEnvironment type for this test or null if undefined.testClass - the source test classSpringBootTest.WebEnvironment or nullprotected java.lang.Class<?>[] getClasses(java.lang.Class<?> testClass)
protected java.lang.String[] getProperties(java.lang.Class<?> testClass)
protected SpringBootTest getAnnotation(java.lang.Class<?> testClass)
protected void verifyConfiguration(java.lang.Class<?> testClass)
protected final org.springframework.test.context.MergedContextConfiguration createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig,
java.lang.Class<?>[] classes)
MergedContextConfiguration with different classes.mergedConfig - the source configclasses - the replacement classesMergedContextConfigurationprotected final org.springframework.test.context.MergedContextConfiguration createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig,
java.lang.Class<?>[] classes,
java.lang.String[] propertySourceProperties)
MergedContextConfiguration with different classes and
properties.mergedConfig - the source configclasses - the replacement classespropertySourceProperties - the replacement propertiesMergedContextConfiguration