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). Never starts an embedded web server,
but detects the @WebAppConfiguration annotation on the test
class and only creates a web application context if it is present. Non-web features,
like a repository layer, can be tested cleanly by simply not marking the test
class @WebAppConfiguration.
If @ActiveProfiles are provided in the test class they will be used to
create the application context.
| 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 String |
getResourceSuffix() |
protected SpringApplication |
getSpringApplication()
Builds new
SpringApplication instance. |
org.springframework.context.ApplicationContext |
loadContext(org.springframework.test.context.MergedContextConfiguration mergedConfig) |
org.springframework.context.ApplicationContext |
loadContext(String... locations) |
public org.springframework.context.ApplicationContext loadContext(org.springframework.test.context.MergedContextConfiguration mergedConfig)
throws Exception
Exceptionprotected SpringApplication getSpringApplication()
SpringApplication instance. You can
override this method to add custom behaviourSpringApplication instanceprotected 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 getResourceSuffix()
getResourceSuffix in class org.springframework.test.context.support.AbstractContextLoaderCopyright © 2014. All rights reserved.