@@ -530,6 +530,18 @@ public void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnn
530
530
assertEquals (asList ("*Test" , "*Tests" ), patterns );
531
531
}
532
532
533
+ @ Test
534
+ public void findMergedAnnotationWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention () {
535
+ final String [] EMPTY = new String [] {};
536
+ Class <?> element = SpringAppConfigClass .class ;
537
+ ContextConfig contextConfig = findMergedAnnotation (element , ContextConfig .class );
538
+ assertNotNull ("Should find @ContextConfig on " + element , contextConfig );
539
+ assertArrayEquals ("locations for " + element , EMPTY , contextConfig .locations ());
540
+ // 'value' in @SpringAppConfig should not override 'value' in @ContextConfig
541
+ assertArrayEquals ("value for " + element , EMPTY , contextConfig .value ());
542
+ assertArrayEquals ("classes for " + element , new Class <?>[] { Number .class }, contextConfig .classes ());
543
+ }
544
+
533
545
private Set <String > names (Class <?>... classes ) {
534
546
return stream (classes ).map (Class ::getName ).collect (toSet ());
535
547
}
@@ -670,6 +682,8 @@ static class MetaCycleAnnotatedClass {
670
682
671
683
@ AliasFor (attribute = "value" )
672
684
String [] locations () default {};
685
+
686
+ Class <?>[] classes () default {};
673
687
}
674
688
675
689
@ ContextConfig
@@ -725,6 +739,23 @@ static class MetaCycleAnnotatedClass {
725
739
String [] xmlConfigFiles () default "default.xml" ;
726
740
}
727
741
742
+ /**
743
+ * Mock of {@code org.springframework.boot.test.SpringApplicationConfiguration}.
744
+ */
745
+ @ ContextConfig
746
+ @ Retention (RetentionPolicy .RUNTIME )
747
+ @interface SpringAppConfig {
748
+
749
+ @ AliasFor (annotation = ContextConfig .class , attribute = "locations" )
750
+ String [] locations () default {};
751
+
752
+ @ AliasFor ("value" )
753
+ Class <?>[] classes () default {};
754
+
755
+ @ AliasFor ("classes" )
756
+ Class <?>[] value () default {};
757
+ }
758
+
728
759
/**
729
760
* Mock of {@code org.springframework.context.annotation.ComponentScan}
730
761
*/
@@ -909,4 +940,8 @@ static class AliasedComposedContextConfigAndTestPropSourceClass {
909
940
static class TestComponentScanClass {
910
941
}
911
942
943
+ @ SpringAppConfig (Number .class )
944
+ static class SpringAppConfigClass {
945
+ }
946
+
912
947
}
0 commit comments