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,
Class<?>[] classes)
Create a new
MergedContextConfiguration with different classes. |
protected org.springframework.test.context.MergedContextConfiguration |
createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig,
Class<?>[] classes,
String[] propertySourceProperties)
Create a new
MergedContextConfiguration with different classes and
properties. |
protected 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(Class<?> testClass) |
protected Class<?>[] |
getClasses(Class<?> testClass) |
protected Class<? extends org.springframework.test.context.ContextLoader> |
getDefaultContextLoaderClass(Class<?> testClass) |
protected Set<Class<? extends org.springframework.test.context.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(org.springframework.test.context.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 org.springframework.test.context.MergedContextConfiguration |
processMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration mergedConfig) |
protected void |
processPropertySourceProperties(org.springframework.test.context.MergedContextConfiguration mergedConfig,
List<String> propertySourceProperties)
Post process the property source properties, adding or removing elements as
required.
|
protected org.springframework.test.context.ContextLoader |
resolveContextLoader(Class<?> testClass,
List<org.springframework.test.context.ContextConfigurationAttributes> configAttributesList) |
protected void |
verifyConfiguration(Class<?> testClass) |
buildMergedContextConfiguration, getBootstrapContext, getCacheAwareContextLoaderDelegate, getContextCustomizerFactories, getDefaultTestExecutionListenerClassNames, getTestExecutionListeners, resolveExplicitContextLoaderClass, setBootstrapContext
public org.springframework.test.context.TestContext buildTestContext()
buildTestContext
in interface org.springframework.test.context.TestContextBootstrapper
buildTestContext
in class org.springframework.test.context.support.AbstractTestContextBootstrapper
protected Set<Class<? extends org.springframework.test.context.TestExecutionListener>> getDefaultTestExecutionListenerClasses()
getDefaultTestExecutionListenerClasses
in class org.springframework.test.context.support.AbstractTestContextBootstrapper
protected org.springframework.test.context.ContextLoader resolveContextLoader(Class<?> testClass, List<org.springframework.test.context.ContextConfigurationAttributes> configAttributesList)
resolveContextLoader
in class org.springframework.test.context.support.AbstractTestContextBootstrapper
protected Class<? extends org.springframework.test.context.ContextLoader> getDefaultContextLoaderClass(Class<?> testClass)
getDefaultContextLoaderClass
in class org.springframework.test.context.support.DefaultTestContextBootstrapper
protected org.springframework.test.context.MergedContextConfiguration processMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration mergedConfig)
processMergedContextConfiguration
in class org.springframework.test.context.support.AbstractTestContextBootstrapper
protected 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 configure to examineprotected Class<?>[] getOrFindConfigurationClasses(org.springframework.test.context.MergedContextConfiguration mergedConfig)
protected String getDifferentiatorPropertySourceProperty()
null
protected void processPropertySourceProperties(org.springframework.test.context.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 org.springframework.test.context.MergedContextConfiguration createModifiedConfig(org.springframework.test.context.MergedContextConfiguration mergedConfig, Class<?>[] classes)
MergedContextConfiguration
with different classes.mergedConfig
- the source configclasses
- the replacement classesMergedContextConfiguration
protected final org.springframework.test.context.MergedContextConfiguration createModifiedConfig(org.springframework.test.context.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.