Skip to content

Commit 9cea892

Browse files
sbrannensnicoll
authored andcommitted
Use @AliasFor in @SpringApplicationConfiguration
Spring Framework 4.2 introduces first-class support for explicit annotation attribute overrides via a new @AliasFor annotation. In order to avoid potential naming conflicts in the future and to make the current, implicit attribute overrides explicit (as well as documented), this commit retrofits @SpringApplicationConfiguration with @AliasFor. Closes spring-projectsgh-3400 Closes spring-projectsgh-3401
1 parent 1b1ce6b commit 9cea892

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

spring-boot/src/main/java/org/springframework/boot/test/SpringApplicationConfiguration.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@
2525

2626
import org.springframework.context.ApplicationContextInitializer;
2727
import org.springframework.context.ConfigurableApplicationContext;
28+
import org.springframework.core.annotation.AliasFor;
2829
import org.springframework.test.context.ContextConfiguration;
2930

3031
/**
3132
* Class-level annotation that is used to determine how to load and configure an
32-
* ApplicationContext for integration tests. Similar to the standard
33-
* {@link ContextConfiguration} but uses Spring Boot's
34-
* {@link SpringApplicationContextLoader}.
33+
* {@code ApplicationContext} for integration tests.
34+
* <p>Similar to the standard {@link ContextConfiguration @ContextConfiguration}
35+
* but uses Spring Boot's {@link SpringApplicationContextLoader}.
3536
*
3637
* @author Dave Syer
38+
* @author Sam Brannen
3739
* @see SpringApplicationContextLoader
40+
* @see ContextConfiguration
3841
*/
3942
@ContextConfiguration(loader = SpringApplicationContextLoader.class)
4043
@Documented
@@ -44,39 +47,45 @@
4447
public @interface SpringApplicationConfiguration {
4548

4649
/**
47-
* @see ContextConfiguration#locations()
50+
* @see ContextConfiguration#locations
4851
* @return the context configuration locations
4952
*/
53+
@AliasFor(annotation = ContextConfiguration.class, attribute = "locations")
5054
String[] locations() default {};
5155

5256
/**
53-
* @see ContextConfiguration#classes()
57+
* @see ContextConfiguration#classes
5458
* @return the context configuration classes
5559
*/
60+
@AliasFor(annotation = ContextConfiguration.class, attribute = "classes")
5661
Class<?>[] classes() default {};
5762

5863
/**
59-
* @see ContextConfiguration#initializers()
64+
* @see ContextConfiguration#initializers
6065
* @return the context configuration initializers
6166
*/
67+
@AliasFor(annotation = ContextConfiguration.class, attribute = "initializers")
6268
Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>[] initializers() default {};
6369

6470
/**
65-
* @see ContextConfiguration#inheritLocations()
66-
* @return if context locations should be inherited
71+
* @see ContextConfiguration#inheritLocations
72+
* @return {@code true} if context locations should be inherited
6773
*/
74+
@AliasFor(annotation = ContextConfiguration.class, attribute = "inheritLocations")
6875
boolean inheritLocations() default true;
6976

7077
/**
71-
* @see ContextConfiguration#inheritInitializers()
72-
* @return if context initializers should be inherited
78+
* @see ContextConfiguration#inheritInitializers
79+
* @return {@code true} if context initializers should be inherited
7380
*/
81+
@AliasFor(annotation = ContextConfiguration.class, attribute = "inheritInitializers")
7482
boolean inheritInitializers() default true;
7583

7684
/**
77-
* @see ContextConfiguration#name()
78-
* @return if context configuration name
85+
* @see ContextConfiguration#name
86+
* @return the name of the context hierarchy level
7987
*/
88+
@AliasFor(annotation = ContextConfiguration.class, attribute = "name")
8089
String name() default "";
8190

8291
}

0 commit comments

Comments
 (0)