public class SpringBootTestContextBootstrapper extends 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 |
---|---|
TestContext |
buildTestContext() |
protected MergedContextConfiguration |
createModifiedConfig(MergedContextConfiguration mergedConfig,
Class<?>[] classes)
Create a new
MergedContextConfiguration with different classes. |
protected MergedContextConfiguration |
createModifiedConfig(MergedContextConfiguration mergedConfig,
Class<?>[] classes,
String[] propertySourceProperties)
Create a new
MergedContextConfiguration with different classes and
properties. |
protected String |
determineResourceBasePath(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(Class<?> testClass) |
protected Class<?>[] |
getClasses(Class<?> testClass) |
protected Class<? extends ContextLoader> |
getDefaultContextLoaderClass(Class<?> testClass) |
protected Set<Class<? extends TestExecutionListener>> |
getDefaultTestExecutionListenerClasses() |
protected String |
getDifferentiatorPropertySourceProperty()
Return a "differentiator" property to ensure that there is something to
differentiate regular tests and bootstrapped tests.
|
protected Class<?>[] |
getOrFindConfigurationClasses(MergedContextConfiguration mergedConfig) |
protected String[] |
getProperties(Class<?> testClass) |
protected SpringBootTest.WebEnvironment |
getWebEnvironment(Class<?> testClass)
Return the
SpringBootTest.WebEnvironment type for this test or null if undefined. |
protected MergedContextConfiguration |
processMergedContextConfiguration(MergedContextConfiguration mergedConfig) |
protected void |
processPropertySourceProperties(MergedContextConfiguration mergedConfig,
List<String> propertySourceProperties)
Post process the property source properties, adding or removing elements as
required.
|
protected ContextLoader |
resolveContextLoader(Class<?> testClass,
List<ContextConfigurationAttributes> configAttributesList) |
protected void |
verifyConfiguration(Class<?> testClass) |
buildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getDefaultTestExecutionListenerClassNames, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContext
public TestContext buildTestContext()
buildTestContext
in interface TestContextBootstrapper
buildTestContext
in class AbstractTestContextBootstrapper
protected Set<Class<? extends TestExecutionListener>> getDefaultTestExecutionListenerClasses()
getDefaultTestExecutionListenerClasses
in class AbstractTestContextBootstrapper
protected ContextLoader resolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList)
resolveContextLoader
in class AbstractTestContextBootstrapper
protected Class<? extends ContextLoader> getDefaultContextLoaderClass(Class<?> testClass)
getDefaultContextLoaderClass
in class DefaultTestContextBootstrapper
protected MergedContextConfiguration processMergedContextConfiguration(MergedContextConfiguration mergedConfig)
processMergedContextConfiguration
in class AbstractTestContextBootstrapper
protected String determineResourceBasePath(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 Class<?>[] getOrFindConfigurationClasses(MergedContextConfiguration mergedConfig)
protected String getDifferentiatorPropertySourceProperty()
null
protected void processPropertySourceProperties(MergedContextConfiguration mergedConfig, List<String> propertySourceProperties)
mergedConfig
- the merged context configurationpropertySourceProperties
- the property source properties to processprotected SpringBootTest.WebEnvironment getWebEnvironment(Class<?> testClass)
SpringBootTest.WebEnvironment
type for this test or null if undefined.testClass
- the source test classSpringBootTest.WebEnvironment
or null
protected SpringBootTest getAnnotation(Class<?> testClass)
protected void verifyConfiguration(Class<?> testClass)
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes)
MergedContextConfiguration
with different classes.mergedConfig
- the source configclasses
- the replacement classesMergedContextConfiguration
protected final MergedContextConfiguration createModifiedConfig(MergedContextConfiguration mergedConfig, Class<?>[] classes, String[] propertySourceProperties)
MergedContextConfiguration
with different classes and
properties.mergedConfig
- the source configclasses
- the replacement classespropertySourceProperties
- the replacement propertiesMergedContextConfiguration
Copyright © 2020 Pivotal Software, Inc.. All rights reserved.