类 SpringBootContextLoader
- java.lang.Object
- org.springframework.test.context.support.AbstractContextLoader
- org.springframework.boot.test.context.SpringBootContextLoader
- 所有已实现的接口:
org.springframework.test.context.ContextLoader
,org.springframework.test.context.SmartContextLoader
public class SpringBootContextLoader extends org.springframework.test.context.support.AbstractContextLoader
AContextLoader
that can be used to test Spring Boot applications (those that normally startup usingSpringApplication
). Although this loader can be used directly, most test will instead want to use it withSpringBootTest
.The loader supports both standard
MergedContextConfiguration
as well asWebMergedContextConfiguration
. IfWebMergedContextConfiguration
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
构造器概要
构造器 构造器 说明 SpringBootContextLoader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Class<?>[]
detectDefaultConfigurationClasses(Class<?> declaringClass)
Detect the default configuration classes for the supplied test class.protected String[]
getInlinedProperties(org.springframework.test.context.MergedContextConfiguration config)
protected String
getResourceSuffix()
protected String[]
getResourceSuffixes()
protected org.springframework.boot.SpringApplication
getSpringApplication()
Builds newSpringApplication
instance.org.springframework.context.ApplicationContext
loadContext(String... locations)
org.springframework.context.ApplicationContext
loadContext(org.springframework.test.context.MergedContextConfiguration config)
void
processContextConfiguration(org.springframework.test.context.ContextConfigurationAttributes configAttributes)
构造器详细资料
SpringBootContextLoader
public SpringBootContextLoader()
方法详细资料
loadContext
public org.springframework.context.ApplicationContext loadContext(org.springframework.test.context.MergedContextConfiguration config) throws Exception
- 抛出:
Exception
getSpringApplication
protected org.springframework.boot.SpringApplication getSpringApplication()
Builds newSpringApplication
instance. You can override this method to add custom behavior- 返回:
SpringApplication
instance
getInlinedProperties
protected String[] getInlinedProperties(org.springframework.test.context.MergedContextConfiguration config)
processContextConfiguration
public void processContextConfiguration(org.springframework.test.context.ContextConfigurationAttributes configAttributes)
- 指定者:
processContextConfiguration
在接口中org.springframework.test.context.SmartContextLoader
- 覆盖:
processContextConfiguration
在类中org.springframework.test.context.support.AbstractContextLoader
detectDefaultConfigurationClasses
protected Class<?>[] detectDefaultConfigurationClasses(Class<?> declaringClass)
Detect the default configuration classes for the supplied test class. By default simply delegates toAnnotationConfigContextLoaderUtils.detectDefaultConfigurationClasses(java.lang.Class<?>)
.- 参数:
declaringClass
- the test class that declared@ContextConfiguration
- 返回:
- an array of default configuration classes, potentially empty but never
null
- 另请参阅:
AnnotationConfigContextLoaderUtils
loadContext
public org.springframework.context.ApplicationContext loadContext(String... locations) throws Exception
- 抛出:
Exception
getResourceSuffixes
protected String[] getResourceSuffixes()
- 覆盖:
getResourceSuffixes
在类中org.springframework.test.context.support.AbstractContextLoader
getResourceSuffix
protected String getResourceSuffix()
- 指定者:
getResourceSuffix
在类中org.springframework.test.context.support.AbstractContextLoader