org.springframework.test.context
Annotation Type ContextConfiguration


@Retention(value=RUNTIME)
@Target(value=TYPE)
@Inherited
@Documented
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.
 

locations

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

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(locations={"base-context.xml"})
 public class BaseTest {
     // ...
 }
 @ContextConfiguration(locations={"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.

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


Copyright © 2002-2008 The Spring Framework.