Skip to content

Commit 6108ab1

Browse files
committed
Test for expected behavior of getAllMergedAnnotations vs findAllMergedAnnotations
Issue: SPR-15271
1 parent 21ae169 commit 6108ab1

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
import org.junit.internal.ArrayComparisonFailure;
3737
import org.junit.rules.ExpectedException;
3838

39-
import org.springframework.core.annotation.AnnotationUtilsTests.WebController;
40-
import org.springframework.core.annotation.AnnotationUtilsTests.WebMapping;
39+
import org.springframework.core.annotation.AnnotationUtilsTests.*;
4140
import org.springframework.stereotype.Component;
4241
import org.springframework.stereotype.Indexed;
4342
import org.springframework.util.Assert;
@@ -55,6 +54,7 @@
5554
*
5655
* @author Sam Brannen
5756
* @author Rossen Stoyanchev
57+
* @author Juergen Hoeller
5858
* @since 4.0.3
5959
* @see AnnotationUtilsTests
6060
* @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests
@@ -92,6 +92,10 @@ public void getMetaAnnotationTypesOnClassWithMetaDepth2() {
9292
assertEquals(names(TransactionalComponent.class, Transactional.class, Component.class, Indexed.class), names);
9393
}
9494

95+
private Set<String> names(Class<?>... classes) {
96+
return stream(classes).map(Class::getName).collect(toSet());
97+
}
98+
9599
@Test
96100
public void hasMetaAnnotationTypesOnNonAnnotatedClass() {
97101
assertFalse(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME));
@@ -204,15 +208,6 @@ public void getAllAnnotationAttributesOnClassWithMultipleComposedAnnotations() {
204208
attributes.get("value"));
205209
}
206210

207-
@Test
208-
@Ignore("To be validated by ")
209-
public void getAllMergedAnnotationsOnClassWithInterface() throws NoSuchMethodException {
210-
Method m = TransactionalServiceImpl.class.getMethod("doIt");
211-
Set<Transactional> allMergedAnnotations =
212-
getAllMergedAnnotations(m, Transactional.class);
213-
assertEquals(1, allMergedAnnotations.size());
214-
}
215-
216211
@Test
217212
public void getMergedAnnotationAttributesOnClassWithLocalAnnotation() {
218213
Class<?> element = TxConfig.class;
@@ -725,8 +720,18 @@ public void javaxAnnotationTypeViaFindMergedAnnotation() throws Exception {
725720
assertEquals(SpringAppConfigClass.class.getAnnotation(Resource.class), findMergedAnnotation(SpringAppConfigClass.class, Resource.class));
726721
}
727722

728-
private Set<String> names(Class<?>... classes) {
729-
return stream(classes).map(Class::getName).collect(toSet());
723+
@Test
724+
public void getAllMergedAnnotationsOnClassWithInterface() throws Exception {
725+
Method m = TransactionalServiceImpl.class.getMethod("doIt");
726+
Set<Transactional> allMergedAnnotations = getAllMergedAnnotations(m, Transactional.class);
727+
assertTrue(allMergedAnnotations.isEmpty());
728+
}
729+
730+
@Test
731+
public void findAllMergedAnnotationsOnClassWithInterface() throws Exception {
732+
Method m = TransactionalServiceImpl.class.getMethod("doIt");
733+
Set<Transactional> allMergedAnnotations = findAllMergedAnnotations(m, Transactional.class);
734+
assertEquals(1, allMergedAnnotations.size());
730735
}
731736

732737

0 commit comments

Comments
 (0)