Browse Source

Add integration test for gh-24110

pull/24135/head
Sam Brannen 5 years ago
parent
commit
fb13f6f0bc
  1. 40
      spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java

40
spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java

@ -516,6 +516,20 @@ class AnnotatedElementUtilsTests { @@ -516,6 +516,20 @@ class AnnotatedElementUtilsTests {
assertThat(isAnnotated(element, name)).isTrue();
}
@Test
void getMergedAnnotationWithImplicitAliasesWithDefaultsInMetaAnnotationOnComposedAnnotation() {
Class<?> element = ImplicitAliasesWithDefaultsClass.class;
String name = AliasesWithDefaults.class.getName();
AliasesWithDefaults annotation = getMergedAnnotation(element, AliasesWithDefaults.class);
assertThat(annotation).as("Should find @AliasesWithDefaults on " + element.getSimpleName()).isNotNull();
assertThat(annotation.a1()).as("a1").isEqualTo("ImplicitAliasesWithDefaults");
assertThat(annotation.a2()).as("a2").isEqualTo("ImplicitAliasesWithDefaults");
// Verify contracts between utility methods:
assertThat(isAnnotated(element, name)).isTrue();
}
@Test
void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() {
Class<?> element = InvalidConventionBasedComposedContextConfigClass.class;
@ -1064,7 +1078,6 @@ class AnnotatedElementUtilsTests { @@ -1064,7 +1078,6 @@ class AnnotatedElementUtilsTests {
String[] xmlConfigFiles() default {};
}
@ContextConfig
@Retention(RetentionPolicy.RUNTIME)
@interface AliasedComposedContextConfig {
@ -1105,6 +1118,27 @@ class AnnotatedElementUtilsTests { @@ -1105,6 +1118,27 @@ class AnnotatedElementUtilsTests {
@interface ComposedImplicitAliasesContextConfig {
}
@Retention(RetentionPolicy.RUNTIME)
@interface AliasesWithDefaults {
@AliasFor("a2")
String a1() default "AliasesWithDefaults";
@AliasFor("a1")
String a2() default "AliasesWithDefaults";
}
@Retention(RetentionPolicy.RUNTIME)
@AliasesWithDefaults
@interface ImplicitAliasesWithDefaults {
@AliasFor(annotation = AliasesWithDefaults.class, attribute = "a1")
String b1() default "ImplicitAliasesWithDefaults";
@AliasFor(annotation = AliasesWithDefaults.class, attribute = "a2")
String b2() default "ImplicitAliasesWithDefaults";
}
@ImplicitAliasesContextConfig
@Retention(RetentionPolicy.RUNTIME)
@interface TransitiveImplicitAliasesContextConfig {
@ -1410,6 +1444,10 @@ class AnnotatedElementUtilsTests { @@ -1410,6 +1444,10 @@ class AnnotatedElementUtilsTests {
static class ImplicitAliasesContextConfigClass3 {
}
@ImplicitAliasesWithDefaults
static class ImplicitAliasesWithDefaultsClass {
}
@TransitiveImplicitAliasesContextConfig(groovy = "test.groovy")
static class TransitiveImplicitAliasesContextConfigClass {
}

Loading…
Cancel
Save