类 ContextConfigurationAttributes
- java.lang.Object
- org.springframework.test.context.ContextConfigurationAttributes
public class ContextConfigurationAttributes extends Object
ContextConfigurationAttributes
encapsulates the context configuration attributes declared via@ContextConfiguration
.- 从以下版本开始:
- 3.1
- 作者:
- Sam Brannen, Phillip Webb
- 另请参阅:
ContextConfiguration
,SmartContextLoader.processContextConfiguration(ContextConfigurationAttributes)
,MergedContextConfiguration
构造器概要
构造器 构造器 说明 ContextConfigurationAttributes(Class<?> declaringClass)
Construct a newContextConfigurationAttributes
instance with default values.ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers, boolean inheritInitializers, Class<? extends ContextLoader> contextLoaderClass)
Construct a newContextConfigurationAttributes
instance for the test class that declared the@ContextConfiguration
annotation and its corresponding attributes.ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers, boolean inheritInitializers, String name, Class<? extends ContextLoader> contextLoaderClass)
Construct a newContextConfigurationAttributes
instance for the test class that declared the@ContextConfiguration
annotation and its corresponding attributes.ContextConfigurationAttributes(Class<?> declaringClass, AnnotationAttributes annAttrs)
Construct a newContextConfigurationAttributes
instance for the suppliedAnnotationAttributes
(parsed from a@ContextConfiguration
annotation) and the test class that declared them.ContextConfigurationAttributes(Class<?> declaringClass, ContextConfiguration contextConfiguration)
Construct a newContextConfigurationAttributes
instance for the supplied@ContextConfiguration
annotation and the test class that declared it.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
equals(Object other)
Determine if the supplied object is equal to thisContextConfigurationAttributes
instance by comparing both object's declaring class, locations, annotated classes, inheritLocations flag, context initializer classes, inheritInitializers flag, and theContextLoader class
.Class<?>[]
getClasses()
Get the annotated classes that were declared via@ContextConfiguration
.Class<? extends ContextLoader>
getContextLoaderClass()
Get theContextLoader
class that was declared via@ContextConfiguration
.Class<?>
getDeclaringClass()
Get the class that declared the@ContextConfiguration
annotation, either explicitly or implicitly.Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[]
getInitializers()
Get theApplicationContextInitializer
classes that were declared via@ContextConfiguration
.String[]
getLocations()
Get the resource locations that were declared via@ContextConfiguration
.String
getName()
Get the name of the context hierarchy level that was declared via@ContextConfiguration
.boolean
hasClasses()
Determine if thisContextConfigurationAttributes
instance has class-based resources.int
hashCode()
Generate a unique hash code for all properties of thisContextConfigurationAttributes
instance excluding the name.boolean
hasLocations()
Determine if thisContextConfigurationAttributes
instance has path-based resource locations.boolean
hasResources()
Determine if thisContextConfigurationAttributes
instance has either path-based resource locations or class-based resources.boolean
isInheritInitializers()
Get theinheritInitializers
flag that was declared via@ContextConfiguration
.boolean
isInheritLocations()
Get theinheritLocations
flag that was declared via@ContextConfiguration
.void
setClasses(Class<?>... classes)
Set the processed annotated classes, effectively overriding the original value declared via@ContextConfiguration
.void
setLocations(String... locations)
Set the processed resource locations, effectively overriding the original value declared via@ContextConfiguration
.String
toString()
Provide a String representation of the context configuration attributes and declaring class.
构造器详细资料
ContextConfigurationAttributes
public ContextConfigurationAttributes(Class<?> declaringClass)
Construct a newContextConfigurationAttributes
instance with default values.- 参数:
declaringClass
- the test class that declared@ContextConfiguration
, either explicitly or implicitly- 从以下版本开始:
- 4.3
ContextConfigurationAttributes
public ContextConfigurationAttributes(Class<?> declaringClass, ContextConfiguration contextConfiguration)
Construct a newContextConfigurationAttributes
instance for the supplied@ContextConfiguration
annotation and the test class that declared it.- 参数:
declaringClass
- the test class that declared@ContextConfiguration
contextConfiguration
- the annotation from which to retrieve the attributes
ContextConfigurationAttributes
public ContextConfigurationAttributes(Class<?> declaringClass, AnnotationAttributes annAttrs)
Construct a newContextConfigurationAttributes
instance for the suppliedAnnotationAttributes
(parsed from a@ContextConfiguration
annotation) and the test class that declared them.- 参数:
declaringClass
- the test class that declared@ContextConfiguration
annAttrs
- the annotation attributes from which to retrieve the attributes
ContextConfigurationAttributes
public ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers, boolean inheritInitializers, Class<? extends ContextLoader> contextLoaderClass)
Construct a newContextConfigurationAttributes
instance for the test class that declared the@ContextConfiguration
annotation and its corresponding attributes.- 参数:
declaringClass
- the test class that declared@ContextConfiguration
locations
- the resource locations declared via@ContextConfiguration
classes
- the annotated classes declared via@ContextConfiguration
inheritLocations
- theinheritLocations
flag declared via@ContextConfiguration
initializers
- the context initializers declared via@ContextConfiguration
inheritInitializers
- theinheritInitializers
flag declared via@ContextConfiguration
contextLoaderClass
- theContextLoader
class declared via@ContextConfiguration
- 抛出:
IllegalArgumentException
- if thedeclaringClass
orcontextLoaderClass
isnull
ContextConfigurationAttributes
public ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers, boolean inheritInitializers, String name, Class<? extends ContextLoader> contextLoaderClass)
Construct a newContextConfigurationAttributes
instance for the test class that declared the@ContextConfiguration
annotation and its corresponding attributes.- 参数:
declaringClass
- the test class that declared@ContextConfiguration
locations
- the resource locations declared via@ContextConfiguration
classes
- the annotated classes declared via@ContextConfiguration
inheritLocations
- theinheritLocations
flag declared via@ContextConfiguration
initializers
- the context initializers declared via@ContextConfiguration
inheritInitializers
- theinheritInitializers
flag declared via@ContextConfiguration
name
- the name of level in the context hierarchy, ornull
if not applicablecontextLoaderClass
- theContextLoader
class declared via@ContextConfiguration
- 抛出:
IllegalArgumentException
- if thedeclaringClass
orcontextLoaderClass
isnull
方法详细资料
getDeclaringClass
public Class<?> getDeclaringClass()
Get the class that declared the@ContextConfiguration
annotation, either explicitly or implicitly.- 返回:
- the declaring class (never
null
)
setClasses
public void setClasses(Class<?>... classes)
Set the processed annotated classes, effectively overriding the original value declared via@ContextConfiguration
.- 另请参阅:
getClasses()
getClasses
public Class<?>[] getClasses()
Get the annotated classes that were declared via@ContextConfiguration
.Note: this is a mutable property. The returned value may therefore represent a processed value that does not match the original value declared via
@ContextConfiguration
.- 返回:
- the annotated classes; potentially
null
or empty - 另请参阅:
ContextConfiguration.classes()
,setClasses(Class[])
hasClasses
public boolean hasClasses()
Determine if thisContextConfigurationAttributes
instance has class-based resources.- 返回:
true
if theclasses
array is not empty- 另请参阅:
hasResources()
,hasLocations()
setLocations
public void setLocations(String... locations)
Set the processed resource locations, effectively overriding the original value declared via@ContextConfiguration
.- 另请参阅:
getLocations()
getLocations
public String[] getLocations()
Get the resource locations that were declared via@ContextConfiguration
.Note: this is a mutable property. The returned value may therefore represent a processed value that does not match the original value declared via
@ContextConfiguration
.- 返回:
- the resource locations; potentially
null
or empty - 另请参阅:
ContextConfiguration.value()
,ContextConfiguration.locations()
,setLocations(String[])
hasLocations
public boolean hasLocations()
Determine if thisContextConfigurationAttributes
instance has path-based resource locations.- 返回:
true
if thelocations
array is not empty- 另请参阅:
hasResources()
,hasClasses()
hasResources
public boolean hasResources()
Determine if thisContextConfigurationAttributes
instance has either path-based resource locations or class-based resources.- 返回:
true
if either thelocations
or theclasses
array is not empty- 另请参阅:
hasLocations()
,hasClasses()
isInheritLocations
public boolean isInheritLocations()
Get theinheritLocations
flag that was declared via@ContextConfiguration
.- 返回:
- the
inheritLocations
flag - 另请参阅:
ContextConfiguration.inheritLocations()
getInitializers
public Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] getInitializers()
Get theApplicationContextInitializer
classes that were declared via@ContextConfiguration
.- 返回:
- the
ApplicationContextInitializer
classes - 从以下版本开始:
- 3.2
isInheritInitializers
public boolean isInheritInitializers()
Get theinheritInitializers
flag that was declared via@ContextConfiguration
.- 返回:
- the
inheritInitializers
flag - 从以下版本开始:
- 3.2
getName
public String getName()
Get the name of the context hierarchy level that was declared via@ContextConfiguration
.- 返回:
- the name of the context hierarchy level or
null
if not applicable - 从以下版本开始:
- 3.2.2
- 另请参阅:
ContextConfiguration.name()
getContextLoaderClass
public Class<? extends ContextLoader> getContextLoaderClass()
Get theContextLoader
class that was declared via@ContextConfiguration
.- 返回:
- the
ContextLoader
class - 另请参阅:
ContextConfiguration.loader()
equals
public boolean equals(Object other)
Determine if the supplied object is equal to thisContextConfigurationAttributes
instance by comparing both object's declaring class, locations, annotated classes, inheritLocations flag, context initializer classes, inheritInitializers flag, and theContextLoader class
.
hashCode
public int hashCode()
Generate a unique hash code for all properties of thisContextConfigurationAttributes
instance excluding the name.