Add tests for SPR-12738

master
Rossen Stoyanchev 10 years ago
parent facd2401cd
commit b94c6fdf7a
  1. 58
      spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java

@ -22,8 +22,10 @@ import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.util.MultiValueMap;
@ -123,6 +125,35 @@ public class AnnotatedElementUtilsTests {
attributes.getBoolean("readOnly"));
}
// SPR-12738
@Test
public void getAnnotationAttributesInheritedFromInterface() {
String name = Transactional.class.getName();
AnnotationAttributes attributes = getAnnotationAttributes(ConcreteClassWithInheritedAnnotation.class, name);
// assertNotNull(attributes);
}
// SPR-12738
@Test
public void getAnnotationAttributesInheritedFromAbstractMethod() throws NoSuchMethodException {
String name = Transactional.class.getName();
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handle");
AnnotationAttributes attributes = getAnnotationAttributes(method, name);
// assertNotNull(attributes);
}
// SPR-12738
@Test
public void getAnnotationAttributesInheritedFromParameterizedMethod() throws NoSuchMethodException {
String name = Transactional.class.getName();
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handleParameterized", String.class);
AnnotationAttributes attributes = getAnnotationAttributes(ConcreteClassWithInheritedAnnotation.class, name);
// assertNotNull(attributes);
}
// -------------------------------------------------------------------------
@ -154,7 +185,7 @@ public class AnnotatedElementUtilsTests {
// -------------------------------------------------------------------------
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Target({ElementType.TYPE, ElementType.METHOD})
@Documented
@Inherited
@interface Transactional {
@ -226,4 +257,29 @@ public class AnnotatedElementUtilsTests {
static class TxFromMultipleComposedAnnotations {
}
@Transactional
static interface InterfaceWithInheritedAnnotation {
}
static abstract class AbstractClassWithInheritedAnnotation<T> implements InterfaceWithInheritedAnnotation {
@Transactional
public abstract void handle();
@Transactional
public void handleParameterized(T t) {
}
}
static class ConcreteClassWithInheritedAnnotation extends AbstractClassWithInheritedAnnotation<String> {
@Override
public void handle() {
}
@Override
public void handleParameterized(String s) {
}
}
}

Loading…
Cancel
Save