接口的使用
org.springframework.test.context.ContextLoader
使用ContextLoader的程序包 程序包 说明 org.springframework.test.context This package contains the Spring TestContext Framework which provides annotation-driven unit and integration testing support that is agnostic of the actual testing framework in use.org.springframework.test.context.support Support classes for the Spring TestContext Framework.org.springframework.test.context.web Web support classes for the Spring TestContext Framework.org.springframework.test.context中ContextLoader的使用
org.springframework.test.context中ContextLoader的子接口 修饰符和类型 接口 说明 interfaceSmartContextLoaderStrategy interface for loading anapplication contextfor an integration test managed by the Spring TestContext Framework.返回ContextLoader的org.springframework.test.context中的方法 修饰符和类型 方法 说明 ContextLoaderMergedContextConfiguration. getContextLoader()Get the resolvedContextLoaderfor the test class.返回变量类型为ContextLoader的类型的org.springframework.test.context中的方法 修饰符和类型 方法 说明 Class<? extends ContextLoader>ContextConfigurationAttributes. getContextLoaderClass()Get theContextLoaderclass that was declared via@ContextConfiguration.Class<? extends ContextLoader>loader()参数类型为ContextLoader的org.springframework.test.context中的方法 修饰符和类型 方法 说明 protected static StringMergedContextConfiguration. nullSafeClassName(ContextLoader contextLoader)Generate a null-safeStringrepresentation of the suppliedContextLoaderbased solely on the fully qualified name of the loader or "null" if the supplied loader isnull.参数类型为ContextLoader的org.springframework.test.context中的构造器 构造器 说明 MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, String[] activeProfiles, ContextLoader contextLoader)Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader)Create a newMergedContextConfigurationinstance for the supplied parameters.MergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)Create a newMergedContextConfigurationinstance for the supplied parameters.org.springframework.test.context.support中ContextLoader的使用
实现ContextLoader的org.springframework.test.context.support中的类 修饰符和类型 类 说明 classAbstractContextLoaderAbstract application context loader that provides a basis for all concrete implementations of theContextLoaderSPI.classAbstractDelegatingSmartContextLoaderAbstractDelegatingSmartContextLoaderserves as an abstract base class for implementations of theSmartContextLoaderSPI that delegate to a set of candidate SmartContextLoaders (i.e., one that supports XML configuration files or Groovy scripts and one that supports annotated classes) to determine which context loader is appropriate for a given test class's configuration.classAbstractGenericContextLoaderAbstract, generic extension ofAbstractContextLoaderthat loads aGenericApplicationContext.classAnnotationConfigContextLoaderConcrete implementation ofAbstractGenericContextLoaderthat loads bean definitions from component classes.classDelegatingSmartContextLoaderDelegatingSmartContextLoaderis a concrete implementation ofAbstractDelegatingSmartContextLoaderthat delegates to aGenericXmlContextLoader(or aGenericGroovyXmlContextLoaderif Groovy is present in the classpath) and anAnnotationConfigContextLoader.classGenericGroovyXmlContextLoaderConcrete implementation ofAbstractGenericContextLoaderthat reads bean definitions from Groovy scripts and XML configuration files.classGenericPropertiesContextLoaderConcrete implementation ofAbstractGenericContextLoaderthat reads bean definitions from JavaPropertiesresources.classGenericXmlContextLoaderConcrete implementation ofAbstractGenericContextLoaderthat reads bean definitions from XML resources.返回ContextLoader的org.springframework.test.context.support中的方法 修饰符和类型 方法 说明 protected ContextLoaderAbstractTestContextBootstrapper. resolveContextLoader(Class<?> testClass, List<ContextConfigurationAttributes> configAttributesList)Resolve theContextLoaderclass to use for the supplied list ofContextConfigurationAttributesand then instantiate and return thatContextLoader.返回变量类型为ContextLoader的类型的org.springframework.test.context.support中的方法 修饰符和类型 方法 说明 protected abstract Class<? extends ContextLoader>AbstractTestContextBootstrapper. getDefaultContextLoaderClass(Class<?> testClass)Determine the defaultContextLoaderclass to use for the supplied test class.protected Class<? extends ContextLoader>DefaultTestContextBootstrapper. getDefaultContextLoaderClass(Class<?> testClass)ReturnsDelegatingSmartContextLoader.protected Class<? extends ContextLoader>AbstractTestContextBootstrapper. resolveExplicitContextLoaderClass(List<ContextConfigurationAttributes> configAttributesList)org.springframework.test.context.web中ContextLoader的使用
实现ContextLoader的org.springframework.test.context.web中的类 修饰符和类型 类 说明 classAbstractGenericWebContextLoaderAbstract, generic extension ofAbstractContextLoaderthat loads aGenericWebApplicationContext.classAnnotationConfigWebContextLoaderConcrete implementation ofAbstractGenericWebContextLoaderthat loads bean definitions from annotated classes.classGenericGroovyXmlWebContextLoaderConcrete implementation ofAbstractGenericWebContextLoaderthat loads bean definitions from Groovy scripts and XML configuration files.classGenericXmlWebContextLoaderConcrete implementation ofAbstractGenericWebContextLoaderthat loads bean definitions from XML resources.classWebDelegatingSmartContextLoaderWebDelegatingSmartContextLoaderis a concrete implementation ofAbstractDelegatingSmartContextLoaderthat delegates to aGenericXmlWebContextLoader(or aGenericGroovyXmlWebContextLoaderif Groovy is present on the classpath) and anAnnotationConfigWebContextLoader.返回变量类型为ContextLoader的类型的org.springframework.test.context.web中的方法 修饰符和类型 方法 说明 protected Class<? extends ContextLoader>WebTestContextBootstrapper. getDefaultContextLoaderClass(Class<?> testClass)ReturnsWebDelegatingSmartContextLoaderif the supplied class is annotated with@WebAppConfigurationand otherwise delegates to the superclass.参数类型为ContextLoader的org.springframework.test.context.web中的构造器 构造器 说明 WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)Create a newWebMergedContextConfigurationinstance for the supplied parameters.WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes, Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, Set<ContextCustomizer> contextCustomizers, String resourceBasePath, ContextLoader contextLoader, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent)Create a newWebMergedContextConfigurationinstance for the supplied parameters.