public class SpringApplicationContextLoader
extends org.springframework.test.context.support.AbstractContextLoader
ContextLoader that can be used to test Spring Boot applications (those that
normally startup using SpringApplication). Can be used to test non-web features
(like a repository layer) or start an fully-configured embedded servlet container.
Use @WebIntegrationTest (or @IntegrationTest with
@WebAppConfiguration) to indicate that you want to use a real servlet container
or @WebAppConfiguration alone to use a MockServletContext.
If @ActiveProfiles are provided in the test class they will be used to create
the application context.
IntegrationTest,
WebIntegrationTest,
TestRestTemplate| Constructor and Description |
|---|
SpringApplicationContextLoader() |
| Modifier and Type | Method and Description |
|---|---|
protected Class<?>[] |
detectDefaultConfigurationClasses(Class<?> declaringClass)
Detect the default configuration classes for the supplied test class.
|
protected Map<String,Object> |
getEnvironmentProperties(org.springframework.test.context.MergedContextConfiguration config) |
protected String |
getResourceSuffix() |
protected String[] |
getResourceSuffixes() |
protected SpringApplication |
getSpringApplication()
Builds new
SpringApplication instance. |
org.springframework.context.ApplicationContext |
loadContext(org.springframework.test.context.MergedContextConfiguration config) |
org.springframework.context.ApplicationContext |
loadContext(String... locations) |
void |
processContextConfiguration(org.springframework.test.context.ContextConfigurationAttributes configAttributes) |
public org.springframework.context.ApplicationContext loadContext(org.springframework.test.context.MergedContextConfiguration config)
throws Exception
Exceptionprotected SpringApplication getSpringApplication()
SpringApplication instance. You can
override this method to add custom behaviorSpringApplication instanceprotected Map<String,Object> getEnvironmentProperties(org.springframework.test.context.MergedContextConfiguration config)
public void processContextConfiguration(org.springframework.test.context.ContextConfigurationAttributes configAttributes)
processContextConfiguration in interface org.springframework.test.context.SmartContextLoaderprocessContextConfiguration in class org.springframework.test.context.support.AbstractContextLoaderprotected Class<?>[] detectDefaultConfigurationClasses(Class<?> declaringClass)
AnnotationConfigContextLoaderUtils.detectDefaultConfigurationClasses(java.lang.Class<?>) .declaringClass - the test class that declared @ContextConfigurationnullAnnotationConfigContextLoaderUtilspublic org.springframework.context.ApplicationContext loadContext(String... locations) throws Exception
Exceptionprotected String[] getResourceSuffixes()
getResourceSuffixes in class org.springframework.test.context.support.AbstractContextLoaderprotected String getResourceSuffix()
getResourceSuffix in class org.springframework.test.context.support.AbstractContextLoaderCopyright © 2016 Pivotal Software, Inc.. All rights reserved.