|
22 | 22 | import java.lang.annotation.Retention; |
23 | 23 | import java.lang.annotation.RetentionPolicy; |
24 | 24 | import java.lang.annotation.Target; |
| 25 | +import java.lang.reflect.Method; |
25 | 26 | import java.util.Arrays; |
26 | 27 |
|
| 28 | +import org.junit.Ignore; |
27 | 29 | import org.junit.Test; |
28 | 30 |
|
29 | 31 | import org.springframework.util.MultiValueMap; |
@@ -123,6 +125,35 @@ public void getAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLoc |
123 | 125 | attributes.getBoolean("readOnly")); |
124 | 126 | } |
125 | 127 |
|
| 128 | + // SPR-12738 |
| 129 | + |
| 130 | + @Test |
| 131 | + public void getAnnotationAttributesInheritedFromInterface() { |
| 132 | + String name = Transactional.class.getName(); |
| 133 | + AnnotationAttributes attributes = getAnnotationAttributes(ConcreteClassWithInheritedAnnotation.class, name); |
| 134 | +// assertNotNull(attributes); |
| 135 | + } |
| 136 | + |
| 137 | + // SPR-12738 |
| 138 | + |
| 139 | + @Test |
| 140 | + public void getAnnotationAttributesInheritedFromAbstractMethod() throws NoSuchMethodException { |
| 141 | + String name = Transactional.class.getName(); |
| 142 | + Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handle"); |
| 143 | + AnnotationAttributes attributes = getAnnotationAttributes(method, name); |
| 144 | +// assertNotNull(attributes); |
| 145 | + } |
| 146 | + |
| 147 | + // SPR-12738 |
| 148 | + |
| 149 | + @Test |
| 150 | + public void getAnnotationAttributesInheritedFromParameterizedMethod() throws NoSuchMethodException { |
| 151 | + String name = Transactional.class.getName(); |
| 152 | + Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handleParameterized", String.class); |
| 153 | + AnnotationAttributes attributes = getAnnotationAttributes(ConcreteClassWithInheritedAnnotation.class, name); |
| 154 | +// assertNotNull(attributes); |
| 155 | + } |
| 156 | + |
126 | 157 |
|
127 | 158 | // ------------------------------------------------------------------------- |
128 | 159 |
|
@@ -154,7 +185,7 @@ static class MetaCycleAnnotatedClass { |
154 | 185 | // ------------------------------------------------------------------------- |
155 | 186 |
|
156 | 187 | @Retention(RetentionPolicy.RUNTIME) |
157 | | - @Target(ElementType.TYPE) |
| 188 | + @Target({ElementType.TYPE, ElementType.METHOD}) |
158 | 189 | @Documented |
159 | 190 | @Inherited |
160 | 191 | @interface Transactional { |
@@ -226,4 +257,29 @@ static class DerivedTxConfig extends TxConfig { |
226 | 257 | static class TxFromMultipleComposedAnnotations { |
227 | 258 | } |
228 | 259 |
|
| 260 | + @Transactional |
| 261 | + static interface InterfaceWithInheritedAnnotation { |
| 262 | + } |
| 263 | + |
| 264 | + static abstract class AbstractClassWithInheritedAnnotation<T> implements InterfaceWithInheritedAnnotation { |
| 265 | + |
| 266 | + @Transactional |
| 267 | + public abstract void handle(); |
| 268 | + |
| 269 | + @Transactional |
| 270 | + public void handleParameterized(T t) { |
| 271 | + } |
| 272 | + } |
| 273 | + |
| 274 | + static class ConcreteClassWithInheritedAnnotation extends AbstractClassWithInheritedAnnotation<String> { |
| 275 | + |
| 276 | + @Override |
| 277 | + public void handle() { |
| 278 | + } |
| 279 | + |
| 280 | + @Override |
| 281 | + public void handleParameterized(String s) { |
| 282 | + } |
| 283 | + } |
| 284 | + |
229 | 285 | } |
0 commit comments