|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2011 the original author or authors. |
| 2 | + * Copyright 2002-2012 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
23 | 23 | import java.lang.annotation.RetentionPolicy;
|
24 | 24 | import java.lang.annotation.Target;
|
25 | 25 |
|
| 26 | +import org.springframework.context.annotation.Bean; |
| 27 | +import org.springframework.context.annotation.Configuration; |
| 28 | + |
26 | 29 | /**
|
27 | 30 | * {@code ContextConfiguration} defines class-level metadata that is
|
28 | 31 | * used to determine how to load and configure an
|
29 | 32 | * {@link org.springframework.context.ApplicationContext ApplicationContext}
|
30 | 33 | * for test classes.
|
31 |
| - * |
| 34 | + * |
| 35 | + * <h3>Supported Resource Types</h3> |
| 36 | + * |
32 | 37 | * <p>Prior to Spring 3.1, only path-based resource locations were supported.
|
33 | 38 | * As of Spring 3.1, {@link #loader context loaders} may choose to support
|
34 | 39 | * either path-based or class-based resources (but not both). Consequently
|
35 | 40 | * {@code @ContextConfiguration} can be used to declare either path-based
|
36 | 41 | * resource locations (via the {@link #locations} or {@link #value}
|
37 |
| - * attribute) <i>or</i> configuration classes (via the {@link #classes} |
| 42 | + * attribute) <i>or</i> annotated classes (via the {@link #classes} |
38 | 43 | * attribute).
|
39 |
| - * |
| 44 | + * |
| 45 | + * <h3>Annotated Classes</h3> |
| 46 | + * |
| 47 | + * <p>The term <em>annotated class</em> can refer to any of the following. |
| 48 | + * |
| 49 | + * <ul> |
| 50 | + * <li>A class annotated with {@link Configuration @Configuration}</li> |
| 51 | + * <li>A component (i.e., a class annotated with |
| 52 | + * {@link org.springframework.stereotype.Component @Component}, |
| 53 | + * {@link org.springframework.stereotype.Service @Service}, |
| 54 | + * {@link org.springframework.stereotype.Repository @Repository}, etc.)</li> |
| 55 | + * <li>A JSR-330 compliant class that is annotated with {@code javax.inject} annotations</li> |
| 56 | + * <li>Any other class that contains {@link Bean @Bean}-methods</li> |
| 57 | + * </ul> |
| 58 | + * |
| 59 | + * Consult the JavaDoc for {@link Configuration @Configuration} and {@link Bean @Bean} |
| 60 | + * for further information regarding the configuration and semantics of |
| 61 | + * <em>annotated classes</em>. |
| 62 | + * |
40 | 63 | * @author Sam Brannen
|
41 | 64 | * @since 2.5
|
42 | 65 | * @see ContextLoader
|
|
92 | 115 | String[] locations() default {};
|
93 | 116 |
|
94 | 117 | /**
|
95 |
| - * The {@link org.springframework.context.annotation.Configuration |
96 |
| - * configuration classes} to use for loading an |
| 118 | + * The <em>annotated classes</em> to use for loading an |
97 | 119 | * {@link org.springframework.context.ApplicationContext ApplicationContext}.
|
98 | 120 | *
|
99 | 121 | * <p>Check out the Javadoc for
|
100 | 122 | * {@link org.springframework.test.context.support.AnnotationConfigContextLoader#detectDefaultConfigurationClasses
|
101 | 123 | * AnnotationConfigContextLoader.detectDefaultConfigurationClasses()} for details
|
102 |
| - * on how default configuration classes will be detected if none are specified. |
103 |
| - * See the documentation for {@link #loader} for further details regarding |
104 |
| - * default loaders. |
| 124 | + * on how default configuration classes will be detected if no |
| 125 | + * <em>annotated classes</em> are specified. See the documentation for |
| 126 | + * {@link #loader} for further details regarding default loaders. |
105 | 127 | *
|
106 | 128 | * <p>This attribute may <strong>not</strong> be used in conjunction with
|
107 | 129 | * {@link #locations} or {@link #value}.
|
| 130 | + * |
108 | 131 | * @since 3.1
|
109 | 132 | * @see org.springframework.context.annotation.Configuration
|
110 | 133 | * @see org.springframework.test.context.support.AnnotationConfigContextLoader
|
111 | 134 | */
|
112 | 135 | Class<?>[] classes() default {};
|
113 | 136 |
|
114 | 137 | /**
|
115 |
| - * Whether or not {@link #locations resource locations} or |
116 |
| - * {@link #classes configuration classes} from superclasses should be |
117 |
| - * <em>inherited</em>. |
118 |
| - * |
| 138 | + * Whether or not {@link #locations resource locations} or <em>annotated |
| 139 | + * classes</em> from test superclasses should be <em>inherited</em>. |
| 140 | + * |
119 | 141 | * <p>The default value is <code>true</code>. This means that an annotated
|
120 |
| - * class will <em>inherit</em> the resource locations or configuration |
121 |
| - * classes defined by annotated superclasses. Specifically, the resource |
122 |
| - * locations or configuration classes for an annotated class will be |
123 |
| - * appended to the list of resource locations or configuration classes |
124 |
| - * defined by annotated superclasses. Thus, subclasses have the option of |
125 |
| - * <em>extending</em> the list of resource locations or configuration |
126 |
| - * classes. |
| 142 | + * class will <em>inherit</em> the resource locations or annotated classes |
| 143 | + * defined by test superclasses. Specifically, the resource locations or |
| 144 | + * annotated classes for a given test class will be appended to the list of |
| 145 | + * resource locations or annotated classes defined by test superclasses. |
| 146 | + * Thus, subclasses have the option of <em>extending</em> the list of resource |
| 147 | + * locations or annotated classes. |
127 | 148 | *
|
128 | 149 | * <p>If <code>inheritLocations</code> is set to <code>false</code>, the
|
129 |
| - * resource locations or configuration classes for the annotated class |
| 150 | + * resource locations or annotated classes for the annotated class |
130 | 151 | * will <em>shadow</em> and effectively replace any resource locations
|
131 |
| - * or configuration classes defined by superclasses. |
| 152 | + * or annotated classes defined by superclasses. |
132 | 153 | *
|
133 | 154 | * <p>In the following example that uses path-based resource locations, the
|
134 | 155 | * {@link org.springframework.context.ApplicationContext ApplicationContext}
|
|
149 | 170 | * }
|
150 | 171 | * </pre>
|
151 | 172 | *
|
152 |
| - * <p>Similarly, in the following example that uses configuration |
| 173 | + * <p>Similarly, in the following example that uses annotated |
153 | 174 | * classes, the
|
154 | 175 | * {@link org.springframework.context.ApplicationContext ApplicationContext}
|
155 | 176 | * for {@code ExtendedTest} will be loaded from the
|
|
0 commit comments