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 SpringBootTest |
getAnnotation(Class<?> testClass) |
protected Class<?>[] |
getClasses(Class<?> testClass) |
protected Class<? extends ContextLoader> |
getDefaultContextLoaderClass(Class<?> testClass) |
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) |
buildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getDefaultTestExecutionListenerClasses, getDefaultTestExecutionListenerClassNames, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContext
public TestContext buildTestContext()
buildTestContext
in interface TestContextBootstrapper
buildTestContext
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 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 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 © 2016 Pivotal Software, Inc.. All rights reserved.