Test for expected behavior of getAllMergedAnnotations vs findAllMergedAnnotations
Issue: SPR-15271
This commit is contained in:
parent
21ae169653
commit
6108ab1c31
|
@ -36,8 +36,7 @@ import org.junit.Test;
|
|||
import org.junit.internal.ArrayComparisonFailure;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.WebController;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.WebMapping;
|
||||
import org.springframework.core.annotation.AnnotationUtilsTests.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Indexed;
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -55,6 +54,7 @@ import static org.springframework.core.annotation.AnnotationUtilsTests.*;
|
|||
*
|
||||
* @author Sam Brannen
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Juergen Hoeller
|
||||
* @since 4.0.3
|
||||
* @see AnnotationUtilsTests
|
||||
* @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests
|
||||
|
@ -92,6 +92,10 @@ public class AnnotatedElementUtilsTests {
|
|||
assertEquals(names(TransactionalComponent.class, Transactional.class, Component.class, Indexed.class), names);
|
||||
}
|
||||
|
||||
private Set<String> names(Class<?>... classes) {
|
||||
return stream(classes).map(Class::getName).collect(toSet());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasMetaAnnotationTypesOnNonAnnotatedClass() {
|
||||
assertFalse(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME));
|
||||
|
@ -204,15 +208,6 @@ public class AnnotatedElementUtilsTests {
|
|||
attributes.get("value"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore("To be validated by ")
|
||||
public void getAllMergedAnnotationsOnClassWithInterface() throws NoSuchMethodException {
|
||||
Method m = TransactionalServiceImpl.class.getMethod("doIt");
|
||||
Set<Transactional> allMergedAnnotations =
|
||||
getAllMergedAnnotations(m, Transactional.class);
|
||||
assertEquals(1, allMergedAnnotations.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMergedAnnotationAttributesOnClassWithLocalAnnotation() {
|
||||
Class<?> element = TxConfig.class;
|
||||
|
@ -725,8 +720,18 @@ public class AnnotatedElementUtilsTests {
|
|||
assertEquals(SpringAppConfigClass.class.getAnnotation(Resource.class), findMergedAnnotation(SpringAppConfigClass.class, Resource.class));
|
||||
}
|
||||
|
||||
private Set<String> names(Class<?>... classes) {
|
||||
return stream(classes).map(Class::getName).collect(toSet());
|
||||
@Test
|
||||
public void getAllMergedAnnotationsOnClassWithInterface() throws Exception {
|
||||
Method m = TransactionalServiceImpl.class.getMethod("doIt");
|
||||
Set<Transactional> allMergedAnnotations = getAllMergedAnnotations(m, Transactional.class);
|
||||
assertTrue(allMergedAnnotations.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllMergedAnnotationsOnClassWithInterface() throws Exception {
|
||||
Method m = TransactionalServiceImpl.class.getMethod("doIt");
|
||||
Set<Transactional> allMergedAnnotations = findAllMergedAnnotations(m, Transactional.class);
|
||||
assertEquals(1, allMergedAnnotations.size());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue