|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2016 the original author or authors. |
| 2 | + * Copyright 2002-2017 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
36 | 36 | import org.junit.internal.ArrayComparisonFailure;
|
37 | 37 | import org.junit.rules.ExpectedException;
|
38 | 38 |
|
39 |
| -import org.springframework.core.annotation.AnnotationUtilsTests.WebController; |
40 |
| -import org.springframework.core.annotation.AnnotationUtilsTests.WebMapping; |
| 39 | +import org.springframework.core.annotation.AnnotationUtilsTests.*; |
41 | 40 | import org.springframework.stereotype.Component;
|
42 | 41 | import org.springframework.util.Assert;
|
43 | 42 | import org.springframework.util.MultiValueMap;
|
|
54 | 53 | *
|
55 | 54 | * @author Sam Brannen
|
56 | 55 | * @author Rossen Stoyanchev
|
| 56 | + * @author Juergen Hoeller |
57 | 57 | * @since 4.0.3
|
58 | 58 | * @see AnnotationUtilsTests
|
59 | 59 | * @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests
|
@@ -91,6 +91,10 @@ public void getMetaAnnotationTypesOnClassWithMetaDepth2() {
|
91 | 91 | assertEquals(names(TransactionalComponent.class, Transactional.class, Component.class), names);
|
92 | 92 | }
|
93 | 93 |
|
| 94 | + private Set<String> names(Class<?>... classes) { |
| 95 | + return stream(classes).map(Class::getName).collect(toSet()); |
| 96 | + } |
| 97 | + |
94 | 98 | @Test
|
95 | 99 | public void hasMetaAnnotationTypesOnNonAnnotatedClass() {
|
96 | 100 | assertFalse(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME));
|
@@ -715,8 +719,18 @@ public void javaxAnnotationTypeViaFindMergedAnnotation() throws Exception {
|
715 | 719 | assertEquals(SpringAppConfigClass.class.getAnnotation(Resource.class), findMergedAnnotation(SpringAppConfigClass.class, Resource.class));
|
716 | 720 | }
|
717 | 721 |
|
718 |
| - private Set<String> names(Class<?>... classes) { |
719 |
| - return stream(classes).map(Class::getName).collect(toSet()); |
| 722 | + @Test |
| 723 | + public void getAllMergedAnnotationsOnClassWithInterface() throws Exception { |
| 724 | + Method m = TransactionalServiceImpl.class.getMethod("doIt"); |
| 725 | + Set<Transactional> allMergedAnnotations = getAllMergedAnnotations(m, Transactional.class); |
| 726 | + assertTrue(allMergedAnnotations.isEmpty()); |
| 727 | + } |
| 728 | + |
| 729 | + @Test |
| 730 | + public void findAllMergedAnnotationsOnClassWithInterface() throws Exception { |
| 731 | + Method m = TransactionalServiceImpl.class.getMethod("doIt"); |
| 732 | + Set<Transactional> allMergedAnnotations = findAllMergedAnnotations(m, Transactional.class); |
| 733 | + assertEquals(1, allMergedAnnotations.size()); |
720 | 734 | }
|
721 | 735 |
|
722 | 736 |
|
@@ -1271,4 +1285,17 @@ static class SpringAppConfigClass {
|
1271 | 1285 | static class ResourceHolder {
|
1272 | 1286 | }
|
1273 | 1287 |
|
| 1288 | + interface TransactionalService { |
| 1289 | + |
| 1290 | + @Transactional |
| 1291 | + void doIt(); |
| 1292 | + } |
| 1293 | + |
| 1294 | + class TransactionalServiceImpl implements TransactionalService { |
| 1295 | + |
| 1296 | + @Override |
| 1297 | + public void doIt() { |
| 1298 | + } |
| 1299 | + } |
| 1300 | + |
1274 | 1301 | }
|
0 commit comments