diff --git a/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java b/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java index 42430474c8e95e7f244cae5be0c67b92ccf521da..bfafce1de12060738734fa3d76cae3b1e74fb199 100644 --- a/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java +++ b/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java @@ -33,7 +33,6 @@ import org.springframework.cache.interceptor.CacheEvictOperation; import org.springframework.cache.interceptor.CacheOperation; import org.springframework.cache.interceptor.CacheableOperation; import org.springframework.core.annotation.AliasFor; -import org.springframework.util.ReflectionUtils; import static org.junit.Assert.*; @@ -50,17 +49,6 @@ public class AnnotationCacheOperationSourceTests { private final AnnotationCacheOperationSource source = new AnnotationCacheOperationSource(); - private Collection getOps(Class target, String name, int expectedNumberOfOperations) { - Collection result = getOps(target, name); - assertEquals("Wrong number of operation(s) for '" + name + "'", expectedNumberOfOperations, result.size()); - return result; - } - - private Collection getOps(Class target, String name) { - Method method = ReflectionUtils.findMethod(target, name); - return source.getCacheOperations(method, target); - } - @Test public void singularAnnotation() throws Exception { Collection ops = getOps(AnnotatedClass.class, "singular", 1); @@ -234,6 +222,22 @@ public class AnnotationCacheOperationSourceTests { } + private Collection getOps(Class target, String name, int expectedNumberOfOperations) { + Collection result = getOps(target, name); + assertEquals("Wrong number of operation(s) for '" + name + "'", expectedNumberOfOperations, result.size()); + return result; + } + + private Collection getOps(Class target, String name) { + try { + Method method = target.getMethod(name); + return source.getCacheOperations(method, target); + } + catch (NoSuchMethodException ex) { + throw new IllegalStateException(ex); + } + } + private void assertSharedConfig(CacheOperation actual, String keyGenerator, String cacheManager, String cacheResolver, String... cacheNames) { @@ -241,8 +245,8 @@ public class AnnotationCacheOperationSourceTests { assertEquals("Wrong cache manager", cacheManager, actual.getCacheManager()); assertEquals("Wrong cache resolver", cacheResolver, actual.getCacheResolver()); assertEquals("Wrong number of cache names", cacheNames.length, actual.getCacheNames().size()); - Arrays.stream(cacheNames).forEach( - cacheName -> assertTrue("Cache '" + cacheName + "' not found in " + actual.getCacheNames(), + Arrays.stream(cacheNames).forEach(cacheName -> + assertTrue("Cache '" + cacheName + "' not found in " + actual.getCacheNames(), actual.getCacheNames().contains(cacheName))); }