类 SpringBootContextLoader
java.lang.Object
org.springframework.test.context.support.AbstractContextLoader
org.springframework.boot.test.context.SpringBootContextLoader
- 所有已实现的接口:
AotContextLoader
,ContextLoader
,SmartContextLoader
A
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 web
server.
If @ActiveProfiles
are provided in the test class they will be used to create
the application context.
- 从以下版本开始:
- 1.4.0
- 作者:
- Dave Syer, Phillip Webb, Andy Wilkinson, Stephane Nicoll, Madhura Bhave, Scott Frederick
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected Class<?>[]
detectDefaultConfigurationClasses
(Class<?> declaringClass) Detect the default configuration classes for the supplied test class.protected ApplicationContextFactory
getApplicationContextFactory
(MergedContextConfiguration mergedConfig) Return theApplicationContextFactory
that should be used for the test.protected ConfigurableEnvironment
Returns theConfigurableEnvironment
instance that should be applied toSpringApplication
ornull
to use the default.protected List
<ApplicationContextInitializer<?>> getInitializers
(MergedContextConfiguration mergedConfig, SpringApplication application) Return theinitializers
that will be applied to the context.protected String[]
getInlinedProperties
(MergedContextConfiguration mergedConfig) protected String
protected String[]
protected SpringApplication
Builds newSpringApplication
instance.loadContext
(MergedContextConfiguration mergedConfig) loadContextForAotProcessing
(MergedContextConfiguration mergedConfig, RuntimeHints runtimeHints) loadContextForAotRuntime
(MergedContextConfiguration mergedConfig, ApplicationContextInitializer<ConfigurableApplicationContext> initializer) void
processContextConfiguration
(ContextConfigurationAttributes configAttributes) 从类继承的方法 org.springframework.test.context.support.AbstractContextLoader
customizeContext, generateDefaultLocations, isGenerateDefaultLocations, modifyLocations, prepareContext, processLocations
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.test.context.aot.AotContextLoader
loadContextForAotProcessing
从接口继承的方法 org.springframework.test.context.SmartContextLoader
loadContext, processLocations
-
构造器详细资料
-
SpringBootContextLoader
public SpringBootContextLoader()
-
-
方法详细资料
-
loadContext
- 指定者:
loadContext
在接口中SmartContextLoader
- 抛出:
Exception
-
loadContextForAotProcessing
public ApplicationContext loadContextForAotProcessing(MergedContextConfiguration mergedConfig, RuntimeHints runtimeHints) throws Exception - 指定者:
loadContextForAotProcessing
在接口中AotContextLoader
- 抛出:
Exception
-
loadContextForAotRuntime
public ApplicationContext loadContextForAotRuntime(MergedContextConfiguration mergedConfig, ApplicationContextInitializer<ConfigurableApplicationContext> initializer) throws Exception - 指定者:
loadContextForAotRuntime
在接口中AotContextLoader
- 抛出:
Exception
-
getApplicationContextFactory
protected ApplicationContextFactory getApplicationContextFactory(MergedContextConfiguration mergedConfig) Return theApplicationContextFactory
that should be used for the test. By default this method will return a factory that will create an appropriateApplicationContext
for theWebApplicationType
.- 参数:
mergedConfig
- the merged context configuration- 返回:
- the application context factory to use
- 从以下版本开始:
- 3.2.0
-
getSpringApplication
Builds newSpringApplication
instance. This method is only called when amain
method isn't being used to create theSpringApplication
.- 返回:
- a
SpringApplication
instance
-
getEnvironment
Returns theConfigurableEnvironment
instance that should be applied toSpringApplication
ornull
to use the default. You can override this method if you need a custom environment.- 返回:
- a
ConfigurableEnvironment
instance
-
getInlinedProperties
-
getInitializers
protected List<ApplicationContextInitializer<?>> getInitializers(MergedContextConfiguration mergedConfig, SpringApplication application) Return theinitializers
that will be applied to the context. By default this method will adaptcontext customizers
, addapplication initializers
and addinitializers specified on the test
.- 参数:
mergedConfig
- the source context configurationapplication
- the application instance- 返回:
- the initializers to apply
- 从以下版本开始:
- 2.0.0
-
processContextConfiguration
-
detectDefaultConfigurationClasses
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
- 另请参阅:
-
getResourceSuffixes
-
getResourceSuffix
- 指定者:
getResourceSuffix
在类中AbstractContextLoader
-