@ -491,6 +491,30 @@ public class AnnotatedElementUtilsTests {
@@ -491,6 +491,30 @@ public class AnnotatedElementUtilsTests {
assertEquals ( "TX qualifier via synthesized annotation." , "aliasForQualifier" , annotation . qualifier ( ) ) ;
}
@Test
public void findMergedAnnotationForMultipleMetaAnnotationsWithClashingAttributeNames ( ) {
final String [ ] xmlLocations = new String [ ] { "test.xml" } ;
final String [ ] propFiles = new String [ ] { "test.properties" } ;
Class < ? > element = AliasedComposedContextConfigAndTestPropSourceClass . class ;
ContextConfig contextConfig = findMergedAnnotation ( element , ContextConfig . class ) ;
assertNotNull ( "@ContextConfig on " + element , contextConfig ) ;
assertArrayEquals ( "locations" , xmlLocations , contextConfig . locations ( ) ) ;
assertArrayEquals ( "value" , xmlLocations , contextConfig . value ( ) ) ;
// Synthesized annotation
TestPropSource testPropSource = AnnotationUtils . findAnnotation ( element , TestPropSource . class ) ;
assertArrayEquals ( "locations" , propFiles , testPropSource . locations ( ) ) ;
assertArrayEquals ( "value" , propFiles , testPropSource . value ( ) ) ;
// Merged annotation
testPropSource = findMergedAnnotation ( element , TestPropSource . class ) ;
assertNotNull ( "@TestPropSource on " + element , testPropSource ) ;
assertArrayEquals ( "locations" , propFiles , testPropSource . locations ( ) ) ;
assertArrayEquals ( "value" , propFiles , testPropSource . value ( ) ) ;
}
@Test
public void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation ( ) {
Class < ? > element = TestComponentScanClass . class ;
@ -622,6 +646,19 @@ public class AnnotatedElementUtilsTests {
@@ -622,6 +646,19 @@ public class AnnotatedElementUtilsTests {
@interface MetaAndLocalTxConfig {
}
/ * *
* Mock of { @code org . springframework . test . context . TestPropertySource } .
* /
@Retention ( RetentionPolicy . RUNTIME )
@interface TestPropSource {
@AliasFor ( "locations" )
String [ ] value ( ) default { } ;
@AliasFor ( "value" )
String [ ] locations ( ) default { } ;
}
/ * *
* Mock of { @code org . springframework . test . context . ContextConfiguration } .
* /
@ -679,6 +716,15 @@ public class AnnotatedElementUtilsTests {
@@ -679,6 +716,15 @@ public class AnnotatedElementUtilsTests {
String [ ] xmlConfigFiles ( ) ;
}
@ContextConfig ( locations = "shadowed.xml" )
@TestPropSource ( locations = "test.properties" )
@Retention ( RetentionPolicy . RUNTIME )
@interface AliasedComposedContextConfigAndTestPropSource {
@AliasFor ( annotation = ContextConfig . class , attribute = "locations" )
String [ ] xmlConfigFiles ( ) default "default.xml" ;
}
/ * *
* Mock of { @code org . springframework . context . annotation . ComponentScan }
* /
@ -855,6 +901,10 @@ public class AnnotatedElementUtilsTests {
@@ -855,6 +901,10 @@ public class AnnotatedElementUtilsTests {
static class InvalidAliasedComposedContextConfigClass {
}
@AliasedComposedContextConfigAndTestPropSource ( xmlConfigFiles = "test.xml" )
static class AliasedComposedContextConfigAndTestPropSourceClass {
}
@TestComponentScan ( packages = "com.example.app.test" )
static class TestComponentScanClass {
}