org.springframework.test.context

## Class ContextConfigurationAttributes

- java.lang.Object
- - org.springframework.test.context.ContextConfigurationAttributes

    public class ContextConfigurationAttributes
    extends Object

`ContextConfigurationAttributes` encapsulates the context configuration attributes declared on a test class via `@ContextConfiguration`.

Since:
  3.1
Author:
  Sam Brannen
See Also:
  `ContextConfiguration`, `SmartContextLoader.processContextConfiguration(ContextConfigurationAttributes)`, `MergedContextConfiguration`

### Constructor Summary

Constructors
Constructor and Description
`ContextConfigurationAttributes(Class<?> declaringClass, ContextConfiguration contextConfiguration)` Construct a new `ContextConfigurationAttributes` instance for the supplied `@ContextConfiguration` annotation and the test class that declared it.

`ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes, boolean inheritLocations, Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers, boolean inheritInitializers, Class<? extends ContextLoader> contextLoaderClass)`
Construct a new `ContextConfigurationAttributes` 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 ContextLoader> contextLoaderClass)` Deprecated. as of Spring 3.2, use `ContextConfigurationAttributes(Class, String[], Class[], boolean, Class[], boolean, Class)` instead

### Method Summary

Methods
`Class<?>[]` `getClasses()` Get the annotated classes that were declared via `@ContextConfiguration`.
`Class<? extends ContextLoader>` `getContextLoaderClass()` Get the `ContextLoader` class that was declared via `@ContextConfiguration`.
`Class<?>` `getDeclaringClass()` Get the class that declared the `@ContextConfiguration` annotation.
`Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[]` `getInitializers()` Get the `ApplicationContextInitializer` classes that were declared via `@ContextConfiguration`.
`String[]` `getLocations()` Get the resource locations that were declared via `@ContextConfiguration`.
`boolean` `hasClasses()` Determine if this `ContextConfigurationAttributes` instance has class-based resources.
`boolean` `hasLocations()` Determine if this `ContextConfigurationAttributes` instance has path-based resource locations.
`boolean` `hasResources()` Determine if this `ContextConfigurationAttributes` instance has either path-based resource locations or class-based resources.
`boolean` `isInheritInitializers()` Get the `inheritInitializers` flag that was declared via `@ContextConfiguration`.
`boolean` `isInheritLocations()` Get the `inheritLocations` 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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### ContextConfigurationAttributes

    public ContextConfigurationAttributes(Class<?> declaringClass,
                                  ContextConfiguration contextConfiguration)

Construct a new `ContextConfigurationAttributes` instance for the supplied `@ContextConfiguration` annotation and the test class that declared it.

Parameters:
  `declaringClass` - the test class that declared `@ContextConfiguration`
  `contextConfiguration` - the annotation from which to retrieve the attributes

#### ContextConfigurationAttributes

    @Deprecated
    public ContextConfigurationAttributes(Class<?> declaringClass,
                                             String[] locations,
                                             Class<?>[] classes,
                                             boolean inheritLocations,
                                             Class<? extends ContextLoader> contextLoaderClass)

Deprecated. as of Spring 3.2, use `ContextConfigurationAttributes(Class, String[], Class[], boolean, Class[], boolean, Class)` instead
Construct a new `ContextConfigurationAttributes` instance for the test class that declared the `@ContextConfiguration` annotation 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 `inheritLocations` flag declared via `@ContextConfiguration`
  `contextLoaderClass` - the `ContextLoader` class declared via `@ContextConfiguration`
Throws:
  `IllegalArgumentException` - if the `declaringClass` or `contextLoaderClass` is `null`, or if the `locations` and `classes` are both non-empty

#### 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 new `ContextConfigurationAttributes` instance for the test class that declared the `@ContextConfiguration` annotation 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 `inheritLocations` flag declared via `@ContextConfiguration`
  `initializers` - the context initializers declared via `@ContextConfiguration`
  `inheritInitializers` - the `inheritInitializers` flag declared via `@ContextConfiguration`
  `contextLoaderClass` - the `ContextLoader` class declared via `@ContextConfiguration`
Throws:
  `IllegalArgumentException` - if the `declaringClass` or `contextLoaderClass` is `null`, or if the `locations` and `classes` are both non-empty

### Method Detail

#### getDeclaringClass

    public Class<?> getDeclaringClass()

Get the class that declared the `@ContextConfiguration` annotation.

Returns:
  the declaring class; never `null`

#### 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`.

Returns:
  the resource locations; potentially `null` or empty
See Also:
  `ContextConfiguration.value()`, `ContextConfiguration.locations()`, `setLocations(String[])`

#### setLocations

    public void setLocations(String[] locations)

Set the processed resource locations, effectively overriding the original value declared via `@ContextConfiguration`.

See Also:
  `getLocations()`

#### 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`.

Returns:
  the annotated classes; potentially `null` or empty
See Also:
  `ContextConfiguration.classes()`, `setClasses(Class[])`

#### setClasses

    public void setClasses(Class<?>[] classes)

Set the processed annotated classes, effectively overriding the original value declared via `@ContextConfiguration`.

See Also:
  `getClasses()`

#### hasLocations

    public boolean hasLocations()

Determine if this `ContextConfigurationAttributes` instance has path-based resource locations.

Returns:
  `true` if the `locations` array is not empty
See Also:
  `hasResources()`, `hasClasses()`

#### hasClasses

    public boolean hasClasses()

Determine if this `ContextConfigurationAttributes` instance has class-based resources.

Returns:
  `true` if the `classes` array is not empty
See Also:
  `hasResources()`, `hasLocations()`

#### hasResources

    public boolean hasResources()

Determine if this `ContextConfigurationAttributes` instance has either path-based resource locations or class-based resources.

Returns:
  `true` if either the `locations` or the `classes` array is not empty
See Also:
  `hasLocations()`, `hasClasses()`

#### isInheritLocations

    public boolean isInheritLocations()

Get the `inheritLocations` flag that was declared via `@ContextConfiguration`.

Returns:
  the `inheritLocations` flag
See Also:
  `ContextConfiguration.inheritLocations()`

#### getInitializers

    public Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] getInitializers()

Get the `ApplicationContextInitializer` classes that were declared via `@ContextConfiguration`.

Returns:
  the `ApplicationContextInitializer` classes
Since:
  3.2

#### isInheritInitializers

    public boolean isInheritInitializers()

Get the `inheritInitializers` flag that was declared via `@ContextConfiguration`.

Returns:
  the `inheritInitializers` flag
Since:
  3.2

#### getContextLoaderClass

    public Class<? extends ContextLoader> getContextLoaderClass()

Get the `ContextLoader` class that was declared via `@ContextConfiguration`.

Returns:
  the `ContextLoader` class
See Also:
  `ContextConfiguration.loader()`

#### toString

    public String toString()

Provide a String representation of the context configuration attributes and declaring class.

Overrides:
  `toString` in class `Object`