org.springframework.test.context
Annotation Type ContextConfiguration


@Documented
@Inherited
@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface ContextConfiguration

ContextConfiguration defines class-level metadata which can be used to instruct client code with regard to how to load and configure an ApplicationContext.

Since:
2.5
Author:
Sam Brannen
See Also:
ContextLoader, ApplicationContext

Optional Element Summary
 boolean inheritLocations
          Whether or not resource locations from superclasses should be inherited.
 Class<? extends ContextLoader> loader
          The type of ContextLoader to use for loading an ApplicationContext.
 String[] locations
          The resource locations to use for loading an ApplicationContext.
 String[] value
          Alias for locations.
 

locations

public abstract String[] locations
The resource locations to use for loading an ApplicationContext.

Default:
{}

value

public abstract String[] value
Alias for locations.

Since:
3.0
Default:
{}

inheritLocations

public abstract boolean inheritLocations
Whether or not resource locations from superclasses should be inherited.

The default value is true, which means that an annotated class will inherit the resource locations defined by an annotated superclass. Specifically, the resource locations for an annotated class will be appended to the list of resource locations defined by an annotated superclass. Thus, subclasses have the option of extending the list of resource locations. In the following example, the ApplicationContext for ExtendedTest will be loaded from "base-context.xml" and "extended-context.xml", in that order. Beans defined in "extended-context.xml" may therefore override those defined in "base-context.xml".

 @ContextConfiguration("base-context.xml")
 public class BaseTest {
        // ...
 }
 
 @ContextConfiguration("extended-context.xml")
 public class ExtendedTest extends BaseTest {
        // ...
 }
 
If inheritLocations is set to false, the resource locations for the annotated class will shadow and effectively replace any resource locations defined by a superclass.

Default:
true

loader

public abstract Class<? extends ContextLoader> loader
The type of ContextLoader to use for loading an ApplicationContext.

If not specified, the loader will be inherited from the first superclass which is annotated with @ContextConfiguration and specifies an explicit loader. If no class in the hierarchy specifies an explicit loader, a default loader will be used instead.

Default:
org.springframework.test.context.ContextLoader.class