public class SpringBootContextLoader extends AbstractContextLoader
ContextLoader that can be used to test Spring Boot applications (those that
normally startup using SpringApplication). Although this loader can be used
directly, most test will instead want to use it with SpringBootTest.
The loader supports both standard MergedContextConfiguration as well as
WebMergedContextConfiguration. If WebMergedContextConfiguration is used
the context will either use a mock servlet environment, or start the full embedded
servlet container.
If @ActiveProfiles are provided in the test class they will be used to create
the application context.
SpringBootTest| Constructor and Description |
|---|
SpringBootContextLoader() |
| Modifier and Type | Method and Description |
|---|---|
protected Class<?>[] |
detectDefaultConfigurationClasses(Class<?> declaringClass)
Detect the default configuration classes for the supplied test class.
|
protected String[] |
getInlinedProperties(MergedContextConfiguration config) |
protected String |
getResourceSuffix() |
protected String[] |
getResourceSuffixes() |
protected SpringApplication |
getSpringApplication()
Builds new
SpringApplication instance. |
ApplicationContext |
loadContext(MergedContextConfiguration config) |
ApplicationContext |
loadContext(String... locations) |
void |
processContextConfiguration(ContextConfigurationAttributes configAttributes) |
customizeContext, generateDefaultLocations, isGenerateDefaultLocations, modifyLocations, prepareContext, processLocationspublic ApplicationContext loadContext(MergedContextConfiguration config) throws Exception
Exceptionprotected SpringApplication getSpringApplication()
SpringApplication instance. You can
override this method to add custom behaviorSpringApplication instanceprotected String[] getInlinedProperties(MergedContextConfiguration config)
public void processContextConfiguration(ContextConfigurationAttributes configAttributes)
processContextConfiguration in interface SmartContextLoaderprocessContextConfiguration in class AbstractContextLoaderprotected Class<?>[] detectDefaultConfigurationClasses(Class<?> declaringClass)
AnnotationConfigContextLoaderUtils.detectDefaultConfigurationClasses(java.lang.Class<?>) .declaringClass - the test class that declared @ContextConfigurationnullAnnotationConfigContextLoaderUtilspublic ApplicationContext loadContext(String... locations) throws Exception
Exceptionprotected String[] getResourceSuffixes()
getResourceSuffixes in class AbstractContextLoaderprotected String getResourceSuffix()
getResourceSuffix in class AbstractContextLoaderCopyright © 2019 Pivotal Software, Inc.. All rights reserved.