|
27 | 27 | import java.util.List;
|
28 | 28 | import java.util.Set;
|
29 | 29 |
|
| 30 | +import org.junit.Ignore; |
30 | 31 | import org.junit.Rule;
|
31 | 32 | import org.junit.Test;
|
32 | 33 | import org.junit.rules.ExpectedException;
|
@@ -294,6 +295,29 @@ public void getMergedAnnotationAttributesWithConventionBasedComposedAnnotation()
|
294 | 295 | assertTrue(isAnnotated(element, name));
|
295 | 296 | }
|
296 | 297 |
|
| 298 | + @Ignore("Disabled until SPR-13554 is addressed") |
| 299 | + @Test |
| 300 | + public void getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation() { |
| 301 | + for (Class<?> clazz : asList(HalfConventionBasedAndHalfAliasedComposedContextConfigClassV1.class, |
| 302 | + HalfConventionBasedAndHalfAliasedComposedContextConfigClassV2.class)) { |
| 303 | + getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation(clazz); |
| 304 | + } |
| 305 | + } |
| 306 | + |
| 307 | + private void getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation(Class<?> clazz) { |
| 308 | + String[] expected = new String[] { "explicitDeclaration" }; |
| 309 | + String name = ContextConfig.class.getName(); |
| 310 | + String simpleName = clazz.getSimpleName(); |
| 311 | + AnnotationAttributes attributes = getMergedAnnotationAttributes(clazz, name); |
| 312 | + |
| 313 | + assertNotNull("Should find @ContextConfig on " + simpleName, attributes); |
| 314 | + assertArrayEquals("locations for class [" + clazz.getSimpleName() + "]", expected, attributes.getStringArray("locations")); |
| 315 | + assertArrayEquals("value for class [" + clazz.getSimpleName() + "]", expected, attributes.getStringArray("value")); |
| 316 | + |
| 317 | + // Verify contracts between utility methods: |
| 318 | + assertTrue(isAnnotated(clazz, name)); |
| 319 | + } |
| 320 | + |
297 | 321 | @Test
|
298 | 322 | public void getMergedAnnotationAttributesWithAliasedComposedAnnotation() {
|
299 | 323 | Class<?> element = AliasedComposedContextConfigClass.class;
|
@@ -772,6 +796,17 @@ static class MetaCycleAnnotatedClass {
|
772 | 796 | String[] locations();
|
773 | 797 | }
|
774 | 798 |
|
| 799 | + @ContextConfig |
| 800 | + @Retention(RetentionPolicy.RUNTIME) |
| 801 | + @interface HalfConventionBasedAndHalfAliasedComposedContextConfig { |
| 802 | + |
| 803 | + String[] locations() default {}; |
| 804 | + |
| 805 | + @AliasFor(annotation = ContextConfig.class, attribute = "locations") |
| 806 | + String[] xmlConfigFiles() default {}; |
| 807 | + } |
| 808 | + |
| 809 | + |
775 | 810 | @ContextConfig
|
776 | 811 | @Retention(RetentionPolicy.RUNTIME)
|
777 | 812 | @interface AliasedComposedContextConfig {
|
@@ -1040,6 +1075,14 @@ static class ConventionBasedComposedContextConfigClass {
|
1040 | 1075 | static class InvalidConventionBasedComposedContextConfigClass {
|
1041 | 1076 | }
|
1042 | 1077 |
|
| 1078 | + @HalfConventionBasedAndHalfAliasedComposedContextConfig(xmlConfigFiles = "explicitDeclaration") |
| 1079 | + static class HalfConventionBasedAndHalfAliasedComposedContextConfigClassV1 { |
| 1080 | + } |
| 1081 | + |
| 1082 | + @HalfConventionBasedAndHalfAliasedComposedContextConfig(locations = "explicitDeclaration") |
| 1083 | + static class HalfConventionBasedAndHalfAliasedComposedContextConfigClassV2 { |
| 1084 | + } |
| 1085 | + |
1043 | 1086 | @AliasedComposedContextConfig(xmlConfigFiles = "test.xml")
|
1044 | 1087 | static class AliasedComposedContextConfigClass {
|
1045 | 1088 | }
|
|
0 commit comments