diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 8230dd59c2e..48d2bd2ab55 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -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.util.Assert; import org.springframework.util.MultiValueMap; @@ -54,6 +53,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 @@ -91,6 +91,10 @@ public class AnnotatedElementUtilsTests { assertEquals(names(TransactionalComponent.class, Transactional.class, Component.class), names); } + private Set names(Class... classes) { + return stream(classes).map(Class::getName).collect(toSet()); + } + @Test public void hasMetaAnnotationTypesOnNonAnnotatedClass() { assertFalse(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME)); @@ -715,8 +719,18 @@ public class AnnotatedElementUtilsTests { assertEquals(SpringAppConfigClass.class.getAnnotation(Resource.class), findMergedAnnotation(SpringAppConfigClass.class, Resource.class)); } - private Set names(Class... classes) { - return stream(classes).map(Class::getName).collect(toSet()); + @Test + public void getAllMergedAnnotationsOnClassWithInterface() throws Exception { + Method m = TransactionalServiceImpl.class.getMethod("doIt"); + Set allMergedAnnotations = getAllMergedAnnotations(m, Transactional.class); + assertTrue(allMergedAnnotations.isEmpty()); + } + + @Test + public void findAllMergedAnnotationsOnClassWithInterface() throws Exception { + Method m = TransactionalServiceImpl.class.getMethod("doIt"); + Set allMergedAnnotations = findAllMergedAnnotations(m, Transactional.class); + assertEquals(1, allMergedAnnotations.size()); } @@ -1271,4 +1285,17 @@ public class AnnotatedElementUtilsTests { static class ResourceHolder { } + interface TransactionalService { + + @Transactional + void doIt(); + } + + class TransactionalServiceImpl implements TransactionalService { + + @Override + public void doIt() { + } + } + }