diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java index 084d64b4d557..fa98731f8c28 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java @@ -18,6 +18,7 @@ import java.lang.reflect.Method; import java.util.Arrays; +import java.util.concurrent.ThreadLocalRandom; import org.junit.Test; import org.junit.runner.RunWith; @@ -64,6 +65,16 @@ public void verifyShouldUseProxyTarget() throws Exception { verify(this.dateService, times(1)).getDate(matchesAnyBoolean()); } + @Test + public void verifyShouldUseProxyTargetWithMethodArguments() throws Exception { + Long d1 = this.dateService.getRandomDate(1234L); + Thread.sleep(200); + Long d2 = this.dateService.getRandomDate(1234L); + assertThat(d1).isEqualTo(d2); + verify(this.dateService, times(1)).getRandomDate(1234L); + } + + private boolean matchesFalse() { if (isTestingMockito1()) { Method method = ReflectionUtils.findMethod( @@ -103,7 +114,7 @@ public CacheResolver cacheResolver(CacheManager cacheManager) { @Bean public ConcurrentMapCacheManager cacheManager() { ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager(); - cacheManager.setCacheNames(Arrays.asList("test")); + cacheManager.setCacheNames(Arrays.asList("test", "test2")); return cacheManager; } @@ -117,6 +128,11 @@ public Long getDate(boolean arg) { return System.nanoTime(); } + @Cacheable(cacheNames = "test2", key = "#seed") + public Long getRandomDate(Long seed) { + return ThreadLocalRandom.current().nextLong(seed); + } + } }