@@ -207,6 +207,70 @@ void searchFromNonAnnotatedStaticNestedClassWithAnnotatedEnclosingClassWithEnclo
207
207
208
208
}
209
209
210
+ @ Nested
211
+ class ConventionBasedAnnotationAttributeOverrideTests {
212
+
213
+ @ Test
214
+ void getWithInheritedAnnotationsAttributesWithConventionBasedComposedAnnotation () {
215
+ MergedAnnotation <?> annotation =
216
+ MergedAnnotations .from (ConventionBasedComposedContextConfigurationClass .class ,
217
+ SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class );
218
+ assertThat (annotation .isPresent ()).isTrue ();
219
+ assertThat (annotation .getStringArray ("locations" )).containsExactly ("explicitDeclaration" );
220
+ assertThat (annotation .getStringArray ("value" )).containsExactly ("explicitDeclaration" );
221
+ }
222
+
223
+ @ Test
224
+ void getWithInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation1 () {
225
+ // SPR-13554: convention mapping mixed with AliasFor annotations
226
+ // xmlConfigFiles can be used because it has an AliasFor annotation
227
+ MergedAnnotation <?> annotation =
228
+ MergedAnnotations .from (HalfConventionBasedAndHalfAliasedComposedContextConfigurationClass1 .class ,
229
+ SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class );
230
+ assertThat (annotation .getStringArray ("locations" )).containsExactly ("explicitDeclaration" );
231
+ assertThat (annotation .getStringArray ("value" )).containsExactly ("explicitDeclaration" );
232
+ }
233
+
234
+ @ Test
235
+ void withInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation2 () {
236
+ // SPR-13554: convention mapping mixed with AliasFor annotations
237
+ // locations doesn't apply because it has no AliasFor annotation
238
+ MergedAnnotation <?> annotation =
239
+ MergedAnnotations .from (HalfConventionBasedAndHalfAliasedComposedContextConfigurationClass2 .class ,
240
+ SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class );
241
+ assertThat (annotation .getStringArray ("locations" )).isEmpty ();
242
+ assertThat (annotation .getStringArray ("value" )).isEmpty ();
243
+ }
244
+
245
+ @ Test
246
+ void getWithInheritedAnnotationsFromInvalidConventionBasedComposedAnnotation () {
247
+ assertThatExceptionOfType (AnnotationConfigurationException .class )
248
+ .isThrownBy (() -> MergedAnnotations .from (InvalidConventionBasedComposedContextConfigurationClass .class ,
249
+ SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class ));
250
+ }
251
+
252
+ @ Test
253
+ void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaConvention () {
254
+ testGetWithTypeHierarchy (ConventionBasedSinglePackageComponentScanClass .class , "com.example.app.test" );
255
+ }
256
+
257
+ @ Test
258
+ void getWithTypeHierarchyWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention () {
259
+ MergedAnnotation <?> annotation =
260
+ MergedAnnotations .from (SpringApplicationConfigurationClass .class , SearchStrategy .TYPE_HIERARCHY )
261
+ .get (ContextConfiguration .class );
262
+ assertThat (annotation .getStringArray ("locations" )).isEmpty ();
263
+ assertThat (annotation .getStringArray ("value" )).isEmpty ();
264
+ assertThat (annotation .getClassArray ("classes" )).containsExactly (Number .class );
265
+ }
266
+
267
+ @ Test
268
+ void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaConvention () throws Exception {
269
+ testGetWithTypeHierarchyWebMapping (WebController .class .getMethod ("postMappedWithPathAttribute" ));
270
+ }
271
+
272
+ }
273
+
210
274
@ Test
211
275
void fromPreconditions () {
212
276
SearchStrategy strategy = SearchStrategy .DIRECT ;
@@ -479,41 +543,7 @@ void getWithInheritedAnnotationsFromNonInheritedAnnotationInterface() {
479
543
assertThat (annotation .isPresent ()).isTrue ();
480
544
}
481
545
482
- @ Test
483
- void getWithInheritedAnnotationsAttributesWithConventionBasedComposedAnnotation () {
484
- MergedAnnotation <?> annotation = MergedAnnotations .from (
485
- ConventionBasedComposedContextConfigurationClass .class ,
486
- SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class );
487
- assertThat (annotation .isPresent ()).isTrue ();
488
- assertThat (annotation .getStringArray ("locations" )).containsExactly (
489
- "explicitDeclaration" );
490
- assertThat (annotation .getStringArray ("value" )).containsExactly (
491
- "explicitDeclaration" );
492
- }
493
-
494
- @ Test
495
- void getWithInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation1 () {
496
- // SPR-13554: convention mapping mixed with AliasFor annotations
497
- // xmlConfigFiles can be used because it has an AliasFor annotation
498
- MergedAnnotation <?> annotation = MergedAnnotations .from (
499
- HalfConventionBasedAndHalfAliasedComposedContextConfigurationClass1 .class ,
500
- SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class );
501
- assertThat (annotation .getStringArray ("locations" )).containsExactly (
502
- "explicitDeclaration" );
503
- assertThat (annotation .getStringArray ("value" )).containsExactly (
504
- "explicitDeclaration" );
505
- }
506
546
507
- @ Test
508
- void withInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation2 () {
509
- // SPR-13554: convention mapping mixed with AliasFor annotations
510
- // locations doesn't apply because it has no AliasFor annotation
511
- MergedAnnotation <?> annotation = MergedAnnotations .from (
512
- HalfConventionBasedAndHalfAliasedComposedContextConfigurationClass2 .class ,
513
- SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class );
514
- assertThat (annotation .getStringArray ("locations" )).isEmpty ();
515
- assertThat (annotation .getStringArray ("value" )).isEmpty ();
516
- }
517
547
518
548
@ Test
519
549
void withInheritedAnnotationsFromAliasedComposedAnnotation () {
@@ -591,13 +621,6 @@ private void testGetWithInherited(Class<?> element, String... expected) {
591
621
assertThat (annotation .getClassArray ("classes" )).isEmpty ();
592
622
}
593
623
594
- @ Test
595
- void getWithInheritedAnnotationsFromInvalidConventionBasedComposedAnnotation () {
596
- assertThatExceptionOfType (AnnotationConfigurationException .class ).isThrownBy (() ->
597
- MergedAnnotations .from (InvalidConventionBasedComposedContextConfigurationClass .class ,
598
- SearchStrategy .INHERITED_ANNOTATIONS ).get (ContextConfiguration .class ));
599
- }
600
-
601
624
@ Test
602
625
void getWithInheritedAnnotationsFromShadowedAliasComposedAnnotation () {
603
626
MergedAnnotation <?> annotation = MergedAnnotations .from (
@@ -760,11 +783,6 @@ void getWithTypeHierarchyFromClassWithBothAttributesOfAnAliasPairDeclared() {
760
783
testGetWithTypeHierarchy (ComponentScanWithBasePackagesAndValueAliasClass .class , "com.example.app.test" );
761
784
}
762
785
763
- @ Test
764
- void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaConvention () {
765
- testGetWithTypeHierarchy (ConventionBasedSinglePackageComponentScanClass .class , "com.example.app.test" );
766
- }
767
-
768
786
@ Test
769
787
void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaAliasFor () {
770
788
testGetWithTypeHierarchy (AliasForBasedSinglePackageComponentScanClass .class , "com.example.app.test" );
@@ -793,22 +811,6 @@ void getWithTypeHierarchyWhenMultipleMetaAnnotationsHaveClashingAttributeNames()
793
811
"test.properties" );
794
812
}
795
813
796
- @ Test
797
- void getWithTypeHierarchyWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention () {
798
- MergedAnnotation <?> annotation = MergedAnnotations .from (
799
- SpringApplicationConfigurationClass .class , SearchStrategy .TYPE_HIERARCHY ).get (
800
- ContextConfiguration .class );
801
- assertThat (annotation .getStringArray ("locations" )).isEmpty ();
802
- assertThat (annotation .getStringArray ("value" )).isEmpty ();
803
- assertThat (annotation .getClassArray ("classes" )).containsExactly (Number .class );
804
- }
805
-
806
- @ Test
807
- void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaConvention () throws Exception {
808
- testGetWithTypeHierarchyWebMapping (
809
- WebController .class .getMethod ("postMappedWithPathAttribute" ));
810
- }
811
-
812
814
@ Test
813
815
void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaAliasFor () throws Exception {
814
816
testGetWithTypeHierarchyWebMapping (
0 commit comments