类 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 ApplicationContextFactorygetApplicationContextFactory(MergedContextConfiguration mergedConfig) Return theApplicationContextFactorythat should be used for the test.protected ConfigurableEnvironmentReturns theConfigurableEnvironmentinstance that should be applied toSpringApplicationornullto use the default.protected List<ApplicationContextInitializer<?>> getInitializers(MergedContextConfiguration mergedConfig, SpringApplication application) Return theinitializersthat will be applied to the context.protected String[]getInlinedProperties(MergedContextConfiguration mergedConfig) protected Stringprotected String[]protected SpringApplicationBuilds newSpringApplicationinstance.loadContext(MergedContextConfiguration mergedConfig) loadContextForAotProcessing(MergedContextConfiguration mergedConfig, RuntimeHints runtimeHints) loadContextForAotRuntime(MergedContextConfiguration mergedConfig, ApplicationContextInitializer<ConfigurableApplicationContext> initializer) voidprocessContextConfiguration(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 theApplicationContextFactorythat should be used for the test. By default this method will return a factory that will create an appropriateApplicationContextfor theWebApplicationType.- 参数:
mergedConfig- the merged context configuration- 返回:
- the application context factory to use
- 从以下版本开始:
- 3.2.0
-
getSpringApplication
Builds newSpringApplicationinstance. This method is only called when amainmethod isn't being used to create theSpringApplication.- 返回:
- a
SpringApplicationinstance
-
getEnvironment
Returns theConfigurableEnvironmentinstance that should be applied toSpringApplicationornullto use the default. You can override this method if you need a custom environment.- 返回:
- a
ConfigurableEnvironmentinstance
-
getInlinedProperties
-
getInitializers
protected List<ApplicationContextInitializer<?>> getInitializers(MergedContextConfiguration mergedConfig, SpringApplication application) Return theinitializersthat will be applied to the context. By default this method will adaptcontext customizers, addapplication initializersand 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
-