|
|
|
@ -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"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -65,8 +65,6 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests { |
|
|
|
assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler()); |
|
|
|
assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// --- local tests -------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void singleCacheManagerBean() throws Throwable { |
|
|
|
public void singleCacheManagerBean() throws Throwable { |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
@ -92,7 +90,7 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests { |
|
|
|
public void multipleCacheManagerBeans_implementsCachingConfigurer() { |
|
|
|
public void multipleCacheManagerBeans_implementsCachingConfigurer() { |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); |
|
|
|
ctx.register(MultiCacheManagerConfigurer.class); |
|
|
|
ctx.register(MultiCacheManagerConfigurer.class); |
|
|
|
ctx.refresh(); // does not throw
|
|
|
|
ctx.refresh(); // does not throw an exception
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test(expected = IllegalStateException.class) |
|
|
|
@Test(expected = IllegalStateException.class) |
|
|
|
@ -125,22 +123,17 @@ public class EnableCachingTests extends AbstractCacheAnnotationTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void emptyConfigSupport() { |
|
|
|
public void emptyConfigSupport() { |
|
|
|
ConfigurableApplicationContext context = |
|
|
|
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class); |
|
|
|
new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CacheInterceptor ci = context.getBean(CacheInterceptor.class); |
|
|
|
CacheInterceptor ci = context.getBean(CacheInterceptor.class); |
|
|
|
assertNotNull(ci.getCacheResolver()); |
|
|
|
assertNotNull(ci.getCacheResolver()); |
|
|
|
assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass()); |
|
|
|
assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass()); |
|
|
|
assertSame(context.getBean(CacheManager.class), |
|
|
|
assertSame(context.getBean(CacheManager.class), ((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager()); |
|
|
|
((SimpleCacheResolver)ci.getCacheResolver()).getCacheManager()); |
|
|
|
|
|
|
|
context.close(); |
|
|
|
context.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void bothSetOnlyResolverIsUsed() { |
|
|
|
public void bothSetOnlyResolverIsUsed() { |
|
|
|
ConfigurableApplicationContext context = |
|
|
|
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class); |
|
|
|
new AnnotationConfigApplicationContext(FullCachingConfig.class); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CacheInterceptor ci = context.getBean(CacheInterceptor.class); |
|
|
|
CacheInterceptor ci = context.getBean(CacheInterceptor.class); |
|
|
|
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver()); |
|
|
|
assertSame(context.getBean("cacheResolver"), ci.getCacheResolver()); |
|
|
|
assertSame(context.getBean("keyGenerator"), ci.getKeyGenerator()); |
|
|
|
assertSame(context.getBean("keyGenerator"), ci.getKeyGenerator()); |
|
|
|
|