类 ContextLoaderUtils
ContextConfigurationAttributes from the
@ContextConfiguration and
@ContextHierarchy annotations for use with
SmartContextLoaders.- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明(专用程序包) static Map<String,List<ContextConfigurationAttributes>> buildContextHierarchyMap(Class<?> testClass) Build a context hierarchy map for the supplied test class and its superclasses, taking into account context hierarchies declared via@ContextHierarchyand@ContextConfiguration.private static voidconvertContextConfigToConfigAttributesAndAddToList(ContextConfiguration contextConfiguration, Class<?> declaringClass, List<ContextConfigurationAttributes> attributesList) Convenience method for creating aContextConfigurationAttributesinstance from the suppliedContextConfigurationannotation and declaring class and then adding the attributes to the supplied list.private static booleanhasResources(ContextConfiguration contextConfiguration) (专用程序包) static List<ContextConfigurationAttributes>resolveContextConfigurationAttributes(Class<?> testClass) Resolve the list of context configuration attributes for the supplied test class and its superclasses.(专用程序包) static List<List<ContextConfigurationAttributes>>resolveContextHierarchyAttributes(Class<?> testClass) Resolve the list of lists of context configuration attributes for the supplied test class and its superclasses, taking into account context hierarchies declared via@ContextHierarchyand@ContextConfiguration.
-
字段详细资料
-
GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX
- 另请参阅:
-
logger
private static final cn.taketoday.logging.Logger logger
-
-
构造器详细资料
-
ContextLoaderUtils
ContextLoaderUtils()
-
-
方法详细资料
-
resolveContextHierarchyAttributes
static List<List<ContextConfigurationAttributes>> resolveContextHierarchyAttributes(Class<?> testClass) Resolve the list of lists of context configuration attributes for the supplied test class and its superclasses, taking into account context hierarchies declared via@ContextHierarchyand@ContextConfiguration.The outer list represents a top-down ordering of context configuration attributes, where each element in the list represents the context configuration declared on a given test class in the class hierarchy. Each nested list contains the context configuration attributes declared either via a single instance of
@ContextConfigurationon the particular class or via multiple instances of@ContextConfigurationdeclared within a single@ContextHierarchyinstance on the particular class. Furthermore, each nested list maintains the order in which@ContextConfigurationinstances are declared.Note that the
inheritLocationsandinheritInitializersflags of@ContextConfigurationwill not be taken into consideration. If these flags need to be honored, that must be handled manually when traversing the nested lists returned by this method.- 参数:
testClass- the class for which to resolve the context hierarchy attributes (must not benull)- 返回:
- the list of lists of configuration attributes for the specified class;
never
null - 抛出:
IllegalArgumentException- if the supplied class isnull; or if neither@ContextConfigurationnor@ContextHierarchyis present on the supplied classIllegalStateException- if a test class or composed annotation in the class hierarchy declares both@ContextConfigurationand@ContextHierarchyas top-level annotations.- 从以下版本开始:
- 4.0
- 另请参阅:
-
buildContextHierarchyMap
static Map<String,List<ContextConfigurationAttributes>> buildContextHierarchyMap(Class<?> testClass) Build a context hierarchy map for the supplied test class and its superclasses, taking into account context hierarchies declared via@ContextHierarchyand@ContextConfiguration.Each value in the map represents the consolidated list of context configuration attributes for a given level in the context hierarchy (potentially across the test class hierarchy), keyed by the
nameof the context hierarchy level.If a given level in the context hierarchy does not have an explicit name (i.e., configured via
ContextConfiguration.name()), a name will be generated for that hierarchy level by appending the numerical level to theGENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX.- 参数:
testClass- the class for which to resolve the context hierarchy map (must not benull)- 返回:
- a map of context configuration attributes for the context hierarchy,
keyed by context hierarchy level name; never
null - 抛出:
IllegalArgumentException- if the lists of context configuration attributes for each level in the@ContextHierarchydo not define unique context configuration within the overall hierarchy.- 从以下版本开始:
- 4.0
- 另请参阅:
-
resolveContextConfigurationAttributes
static List<ContextConfigurationAttributes> resolveContextConfigurationAttributes(Class<?> testClass) Resolve the list of context configuration attributes for the supplied test class and its superclasses.Note that the
inheritLocationsandinheritInitializersflags of@ContextConfigurationwill not be taken into consideration. If these flags need to be honored, that must be handled manually when traversing the list returned by this method.- 参数:
testClass- the class for which to resolve the configuration attributes (must not benull)- 返回:
- the list of configuration attributes for the specified class, ordered
bottom-up (i.e., as if we were traversing up the class hierarchy);
never
null - 抛出:
IllegalArgumentException- if the supplied class isnullor if@ContextConfigurationis not present on the supplied class
-
hasResources
-
convertContextConfigToConfigAttributesAndAddToList
private static void convertContextConfigToConfigAttributesAndAddToList(ContextConfiguration contextConfiguration, Class<?> declaringClass, List<ContextConfigurationAttributes> attributesList) Convenience method for creating aContextConfigurationAttributesinstance from the suppliedContextConfigurationannotation and declaring class and then adding the attributes to the supplied list.
-