Package org.springframework.test.context
Class ContextConfigurationAttributes
java.lang.Object
org.springframework.test.context.ContextConfigurationAttributes
ContextConfigurationAttributes encapsulates the context configuration
 attributes declared via @ContextConfiguration.- Since:
- 3.1
- Author:
- Sam Brannen, Phillip Webb
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionContextConfigurationAttributes(Class<?> declaringClass) Construct a newContextConfigurationAttributesinstance with default values.ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<?>>[] initializers, boolean inheritInitializers, Class<? extends ContextLoader> contextLoaderClass) Construct a newContextConfigurationAttributesinstance for the test class that declared the@ContextConfigurationannotation and its corresponding attributes.ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<?>>[] initializers, boolean inheritInitializers, String name, Class<? extends ContextLoader> contextLoaderClass) Construct a newContextConfigurationAttributesinstance for the test class that declared the@ContextConfigurationannotation and its corresponding attributes.ContextConfigurationAttributes(Class<?> declaringClass, AnnotationAttributes annAttrs) Construct a newContextConfigurationAttributesinstance for the suppliedAnnotationAttributes(parsed from a@ContextConfigurationannotation) and the test class that declared them.ContextConfigurationAttributes(Class<?> declaringClass, ContextConfiguration contextConfiguration) Construct a newContextConfigurationAttributesinstance for the supplied@ContextConfigurationannotation and the test class that declared it.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanDetermine if the supplied object is equal to thisContextConfigurationAttributesinstance by comparing both object's declaring class, locations, annotated classes, inheritLocations flag, context initializer classes, inheritInitializers flag, and theContextLoader class.Class<?>[]Get the annotated classes that were declared via@ContextConfiguration.Class<? extends ContextLoader>Get theContextLoaderclass that was declared via@ContextConfiguration.Class<?>Get the class that declared the@ContextConfigurationannotation, either explicitly or implicitly.Class<? extends ApplicationContextInitializer<?>>[]Get theApplicationContextInitializerclasses that were declared via@ContextConfiguration.String[]Get the resource locations that were declared via@ContextConfiguration.getName()Get the name of the context hierarchy level that was declared via@ContextConfiguration.booleanDetermine if thisContextConfigurationAttributesinstance has class-based resources.inthashCode()Generate a unique hash code for all properties of thisContextConfigurationAttributesinstance excluding the name.booleanDetermine if thisContextConfigurationAttributesinstance has path-based resource locations.booleanDetermine if thisContextConfigurationAttributesinstance has either path-based resource locations or class-based resources.booleanGet theinheritInitializersflag that was declared via@ContextConfiguration.booleanGet theinheritLocationsflag that was declared via@ContextConfiguration.voidsetClasses(Class<?>... classes) Set the processed annotated classes, effectively overriding the original value declared via@ContextConfiguration.voidsetLocations(String... locations) Set the processed resource locations, effectively overriding the original value declared via@ContextConfiguration.toString()Provide a String representation of the context configuration attributes and declaring class.
- 
Constructor Details- 
ContextConfigurationAttributesConstruct a newContextConfigurationAttributesinstance with default values.- Parameters:
- declaringClass- the test class that declared- @ContextConfiguration, either explicitly or implicitly
- Since:
- 4.3
 
- 
ContextConfigurationAttributespublic ContextConfigurationAttributes(Class<?> declaringClass, ContextConfiguration contextConfiguration) Construct a newContextConfigurationAttributesinstance for the supplied@ContextConfigurationannotation and the test class that declared it.- Parameters:
- declaringClass- the test class that declared- @ContextConfiguration
- contextConfiguration- the annotation from which to retrieve the attributes
 
- 
ContextConfigurationAttributesConstruct a newContextConfigurationAttributesinstance for the suppliedAnnotationAttributes(parsed from a@ContextConfigurationannotation) and the test class that declared them.- Parameters:
- declaringClass- the test class that declared- @ContextConfiguration
- annAttrs- the annotation attributes from which to retrieve the attributes
 
- 
ContextConfigurationAttributespublic ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<?>>[] initializers, boolean inheritInitializers, Class<? extends ContextLoader> contextLoaderClass) Construct a newContextConfigurationAttributesinstance for the test class that declared the@ContextConfigurationannotation and its corresponding attributes.- Parameters:
- declaringClass- the test class that declared- @ContextConfiguration
- locations- the resource locations declared via- @ContextConfiguration
- classes- the annotated classes declared via- @ContextConfiguration
- inheritLocations- the- inheritLocationsflag declared via- @ContextConfiguration
- initializers- the context initializers declared via- @ContextConfiguration
- inheritInitializers- the- inheritInitializersflag declared via- @ContextConfiguration
- contextLoaderClass- the- ContextLoaderclass declared via- @ContextConfiguration
- Throws:
- IllegalArgumentException- if the- declaringClassor- contextLoaderClassis- null
 
- 
ContextConfigurationAttributespublic ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<?>>[] initializers, boolean inheritInitializers, @Nullable String name, Class<? extends ContextLoader> contextLoaderClass) Construct a newContextConfigurationAttributesinstance for the test class that declared the@ContextConfigurationannotation and its corresponding attributes.- Parameters:
- declaringClass- the test class that declared- @ContextConfiguration
- locations- the resource locations declared via- @ContextConfiguration
- classes- the annotated classes declared via- @ContextConfiguration
- inheritLocations- the- inheritLocationsflag declared via- @ContextConfiguration
- initializers- the context initializers declared via- @ContextConfiguration
- inheritInitializers- the- inheritInitializersflag declared via- @ContextConfiguration
- name- the name of level in the context hierarchy, or- nullif not applicable
- contextLoaderClass- the- ContextLoaderclass declared via- @ContextConfiguration
- Throws:
- IllegalArgumentException- if the- declaringClassor- contextLoaderClassis- null
 
 
- 
- 
Method Details- 
getDeclaringClassGet the class that declared the@ContextConfigurationannotation, either explicitly or implicitly.- Returns:
- the declaring class (never null)
 
- 
setClassesSet the processed annotated classes, effectively overriding the original value declared via@ContextConfiguration.- See Also:
 
- 
getClassesGet 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.- Returns:
- the annotated classes (potentially {empty)
- See Also:
 
- 
hasClassespublic boolean hasClasses()Determine if thisContextConfigurationAttributesinstance has class-based resources.- Returns:
- trueif the- classesarray is not empty
- See Also:
 
- 
setLocationsSet the processed resource locations, effectively overriding the original value declared via@ContextConfiguration.- See Also:
 
- 
getLocationsGet 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.- Returns:
- the resource locations (potentially empty)
- See Also:
 
- 
hasLocationspublic boolean hasLocations()Determine if thisContextConfigurationAttributesinstance has path-based resource locations.- Returns:
- trueif the- locationsarray is not empty
- See Also:
 
- 
hasResourcespublic boolean hasResources()Determine if thisContextConfigurationAttributesinstance has either path-based resource locations or class-based resources.
- 
isInheritLocationspublic boolean isInheritLocations()Get theinheritLocationsflag that was declared via@ContextConfiguration.- Returns:
- the inheritLocationsflag
- See Also:
 
- 
getInitializersGet theApplicationContextInitializerclasses that were declared via@ContextConfiguration.- Returns:
- the ApplicationContextInitializerclasses
- Since:
- 3.2
 
- 
isInheritInitializerspublic boolean isInheritInitializers()Get theinheritInitializersflag that was declared via@ContextConfiguration.- Returns:
- the inheritInitializersflag
- Since:
- 3.2
 
- 
getNameGet the name of the context hierarchy level that was declared via@ContextConfiguration.- Returns:
- the name of the context hierarchy level or nullif not applicable
- Since:
- 3.2.2
- See Also:
 
- 
getContextLoaderClassGet theContextLoaderclass that was declared via@ContextConfiguration.- Returns:
- the ContextLoaderclass
- See Also:
 
- 
equalsDetermine if the supplied object is equal to thisContextConfigurationAttributesinstance by comparing both object's declaring class, locations, annotated classes, inheritLocations flag, context initializer classes, inheritInitializers flag, and theContextLoader class.
- 
hashCodepublic int hashCode()Generate a unique hash code for all properties of thisContextConfigurationAttributesinstance excluding the name.
- 
toStringProvide a String representation of the context configuration attributes and declaring class.
 
-