@@ -75,7 +75,7 @@ public void caching() throws Exception {
75
75
76
76
@ Test
77
77
public void emptyCaching () throws Exception {
78
- Collection < CacheOperation > ops = getOps (AnnotatedClass .class , "emptyCaching" , 0 );
78
+ getOps (AnnotatedClass .class , "emptyCaching" , 0 );
79
79
}
80
80
81
81
@ Test
@@ -155,7 +155,7 @@ public void customKeyGeneratorInherited() {
155
155
156
156
@ Test
157
157
public void keyAndKeyGeneratorCannotBeSetTogether () {
158
- exception .expect (IllegalStateException .class );
158
+ this . exception .expect (IllegalStateException .class );
159
159
getOps (AnnotatedClass .class , "invalidKeyAndKeyGeneratorSet" );
160
160
}
161
161
@@ -189,7 +189,7 @@ public void customCacheResolverInherited() {
189
189
190
190
@ Test
191
191
public void cacheResolverAndCacheManagerCannotBeSetTogether () {
192
- exception .expect (IllegalStateException .class );
192
+ this . exception .expect (IllegalStateException .class );
193
193
getOps (AnnotatedClass .class , "invalidCacheResolverAndCacheManagerSet" );
194
194
}
195
195
@@ -244,6 +244,22 @@ public void severalCacheConfigUseClosest() {
244
244
assertSharedConfig (cacheOperation , "" , "" , "" , "myCache" );
245
245
}
246
246
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
+
247
263
@ Test
248
264
public void partialClassLevelWithCustomCacheManager () {
249
265
Collection <CacheOperation > ops = getOps (AnnotatedClassWithSomeDefault .class , "methodLevelCacheManager" , 1 );
@@ -275,7 +291,7 @@ private Collection<CacheOperation> getOps(Class<?> target, String name, int expe
275
291
private Collection <CacheOperation > getOps (Class <?> target , String name ) {
276
292
try {
277
293
Method method = target .getMethod (name );
278
- return source .getCacheOperations (method , target );
294
+ return this . source .getCacheOperations (method , target );
279
295
}
280
296
catch (NoSuchMethodException ex ) {
281
297
throw new IllegalStateException (ex );
@@ -430,7 +446,7 @@ public void noCustomization() {
430
446
431
447
432
448
@ CacheConfigFoo
433
- @ CacheConfig (cacheNames = "myCache" ) // multiple sources
449
+ @ CacheConfig (cacheNames = "myCache" ) // multiple sources
434
450
private static class MultipleCacheConfig {
435
451
436
452
@ Cacheable
@@ -439,6 +455,30 @@ public void multipleCacheConfig() {
439
455
}
440
456
441
457
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
+
442
482
@ Retention (RetentionPolicy .RUNTIME )
443
483
@ Target (ElementType .METHOD )
444
484
@ Cacheable ("foo" )
@@ -491,7 +531,7 @@ public void multipleCacheConfig() {
491
531
492
532
493
533
@ Retention (RetentionPolicy .RUNTIME )
494
- @ Target ({ ElementType .METHOD , ElementType .TYPE })
534
+ @ Target ({ElementType .METHOD , ElementType .TYPE })
495
535
@ Cacheable (cacheNames = "shadowed cache name" , key = "shadowed key" )
496
536
@interface ComposedCacheable {
497
537
@@ -507,7 +547,7 @@ public void multipleCacheConfig() {
507
547
508
548
509
549
@ Retention (RetentionPolicy .RUNTIME )
510
- @ Target ({ ElementType .METHOD , ElementType .TYPE })
550
+ @ Target ({ElementType .METHOD , ElementType .TYPE })
511
551
@ CacheEvict (cacheNames = "shadowed cache name" , key = "shadowed key" )
512
552
@interface ComposedCacheEvict {
513
553
0 commit comments