@@ -75,7 +75,7 @@ public void caching() throws Exception {
7575
7676 @ Test
7777 public void emptyCaching () throws Exception {
78- Collection < CacheOperation > ops = getOps (AnnotatedClass .class , "emptyCaching" , 0 );
78+ getOps (AnnotatedClass .class , "emptyCaching" , 0 );
7979 }
8080
8181 @ Test
@@ -155,7 +155,7 @@ public void customKeyGeneratorInherited() {
155155
156156 @ Test
157157 public void keyAndKeyGeneratorCannotBeSetTogether () {
158- exception .expect (IllegalStateException .class );
158+ this . exception .expect (IllegalStateException .class );
159159 getOps (AnnotatedClass .class , "invalidKeyAndKeyGeneratorSet" );
160160 }
161161
@@ -189,7 +189,7 @@ public void customCacheResolverInherited() {
189189
190190 @ Test
191191 public void cacheResolverAndCacheManagerCannotBeSetTogether () {
192- exception .expect (IllegalStateException .class );
192+ this . exception .expect (IllegalStateException .class );
193193 getOps (AnnotatedClass .class , "invalidCacheResolverAndCacheManagerSet" );
194194 }
195195
@@ -244,6 +244,22 @@ public void severalCacheConfigUseClosest() {
244244 assertSharedConfig (cacheOperation , "" , "" , "" , "myCache" );
245245 }
246246
247+ @ Test
248+ public void cacheConfigFromInterface () {
249+ assertNull (getOps (InterfaceCacheConfig .class , "interfaceCacheConfig" ));
250+ Collection <CacheOperation > ops = getOps (CacheConfigIfc .class , "interfaceCacheConfig" );
251+ CacheOperation cacheOperation = ops .iterator ().next ();
252+ assertSharedConfig (cacheOperation , "" , "" , "" , "myCache" );
253+ }
254+
255+ @ Test
256+ public void cacheAnnotationOverride () {
257+ Collection <CacheOperation > ops = getOps (InterfaceCacheConfig .class , "interfaceCacheableOverride" );
258+ assertSame (1 , ops .size ());
259+ CacheOperation cacheOperation = ops .iterator ().next ();
260+ assertTrue (cacheOperation instanceof CacheableOperation );
261+ }
262+
247263 @ Test
248264 public void partialClassLevelWithCustomCacheManager () {
249265 Collection <CacheOperation > ops = getOps (AnnotatedClassWithSomeDefault .class , "methodLevelCacheManager" , 1 );
@@ -275,7 +291,7 @@ private Collection<CacheOperation> getOps(Class<?> target, String name, int expe
275291 private Collection <CacheOperation > getOps (Class <?> target , String name ) {
276292 try {
277293 Method method = target .getMethod (name );
278- return source .getCacheOperations (method , target );
294+ return this . source .getCacheOperations (method , target );
279295 }
280296 catch (NoSuchMethodException ex ) {
281297 throw new IllegalStateException (ex );
@@ -430,7 +446,7 @@ public void noCustomization() {
430446
431447
432448 @ CacheConfigFoo
433- @ CacheConfig (cacheNames = "myCache" ) // multiple sources
449+ @ CacheConfig (cacheNames = "myCache" ) // multiple sources
434450 private static class MultipleCacheConfig {
435451
436452 @ Cacheable
@@ -439,6 +455,30 @@ public void multipleCacheConfig() {
439455 }
440456
441457
458+ @ CacheConfig (cacheNames = "myCache" )
459+ private interface CacheConfigIfc {
460+
461+ @ Cacheable
462+ void interfaceCacheConfig ();
463+
464+ @ CachePut
465+ void interfaceCacheableOverride ();
466+ }
467+
468+
469+ private static class InterfaceCacheConfig implements CacheConfigIfc {
470+
471+ @ Override
472+ public void interfaceCacheConfig () {
473+ }
474+
475+ @ Override
476+ @ Cacheable
477+ public void interfaceCacheableOverride () {
478+ }
479+ }
480+
481+
442482 @ Retention (RetentionPolicy .RUNTIME )
443483 @ Target (ElementType .METHOD )
444484 @ Cacheable ("foo" )
@@ -491,7 +531,7 @@ public void multipleCacheConfig() {
491531
492532
493533 @ Retention (RetentionPolicy .RUNTIME )
494- @ Target ({ ElementType .METHOD , ElementType .TYPE })
534+ @ Target ({ElementType .METHOD , ElementType .TYPE })
495535 @ Cacheable (cacheNames = "shadowed cache name" , key = "shadowed key" )
496536 @interface ComposedCacheable {
497537
@@ -507,7 +547,7 @@ public void multipleCacheConfig() {
507547
508548
509549 @ Retention (RetentionPolicy .RUNTIME )
510- @ Target ({ ElementType .METHOD , ElementType .TYPE })
550+ @ Target ({ElementType .METHOD , ElementType .TYPE })
511551 @ CacheEvict (cacheNames = "shadowed cache name" , key = "shadowed key" )
512552 @interface ComposedCacheEvict {
513553
0 commit comments