Test for expected behavior of getAllMergedAnnotations vs findAllMergedAnnotations
Issue: SPR-15271
This commit is contained in:
@@ -36,8 +36,7 @@ import org.junit.Test;
|
|||||||
import org.junit.internal.ArrayComparisonFailure;
|
import org.junit.internal.ArrayComparisonFailure;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
import org.springframework.core.annotation.AnnotationUtilsTests.WebController;
|
import org.springframework.core.annotation.AnnotationUtilsTests.*;
|
||||||
import org.springframework.core.annotation.AnnotationUtilsTests.WebMapping;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Indexed;
|
import org.springframework.stereotype.Indexed;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@@ -55,6 +54,7 @@ import static org.springframework.core.annotation.AnnotationUtilsTests.*;
|
|||||||
*
|
*
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
* @author Rossen Stoyanchev
|
* @author Rossen Stoyanchev
|
||||||
|
* @author Juergen Hoeller
|
||||||
* @since 4.0.3
|
* @since 4.0.3
|
||||||
* @see AnnotationUtilsTests
|
* @see AnnotationUtilsTests
|
||||||
* @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests
|
* @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests
|
||||||
@@ -92,6 +92,10 @@ public class AnnotatedElementUtilsTests {
|
|||||||
assertEquals(names(TransactionalComponent.class, Transactional.class, Component.class, Indexed.class), names);
|
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
|
@Test
|
||||||
public void hasMetaAnnotationTypesOnNonAnnotatedClass() {
|
public void hasMetaAnnotationTypesOnNonAnnotatedClass() {
|
||||||
assertFalse(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME));
|
assertFalse(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME));
|
||||||
@@ -204,15 +208,6 @@ public class AnnotatedElementUtilsTests {
|
|||||||
attributes.get("value"));
|
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
|
@Test
|
||||||
public void getMergedAnnotationAttributesOnClassWithLocalAnnotation() {
|
public void getMergedAnnotationAttributesOnClassWithLocalAnnotation() {
|
||||||
Class<?> element = TxConfig.class;
|
Class<?> element = TxConfig.class;
|
||||||
@@ -725,8 +720,18 @@ public class AnnotatedElementUtilsTests {
|
|||||||
assertEquals(SpringAppConfigClass.class.getAnnotation(Resource.class), findMergedAnnotation(SpringAppConfigClass.class, Resource.class));
|
assertEquals(SpringAppConfigClass.class.getAnnotation(Resource.class), findMergedAnnotation(SpringAppConfigClass.class, Resource.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<String> names(Class<?>... classes) {
|
@Test
|
||||||
return stream(classes).map(Class::getName).collect(toSet());
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user