JCacheEhCache3Tests enforces EhCache 3.0's CachingProvider
Issue: SPR-13342
This commit is contained in:
parent
f5210ce0c8
commit
3a5cc3df80
|
|
@ -16,9 +16,11 @@
|
|||
|
||||
package org.springframework.cache.jcache;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.cache.CacheManager;
|
||||
import javax.cache.Caching;
|
||||
import javax.cache.configuration.MutableConfiguration;
|
||||
import javax.cache.spi.CachingProvider;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
|
|
@ -48,7 +50,10 @@ public class JCacheEhCacheTests extends AbstractAnnotationTests {
|
|||
|
||||
@Override
|
||||
protected ConfigurableApplicationContext getApplicationContext() {
|
||||
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableCachingConfig.class);
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("cachingProvider", getCachingProvider());
|
||||
context.register(EnableCachingConfig.class);
|
||||
context.refresh();
|
||||
jCacheManager = context.getBean("jCacheManager", CacheManager.class);
|
||||
return context;
|
||||
}
|
||||
|
|
@ -68,10 +73,18 @@ public class JCacheEhCacheTests extends AbstractAnnotationTests {
|
|||
}
|
||||
|
||||
|
||||
protected CachingProvider getCachingProvider() {
|
||||
return Caching.getCachingProvider();
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
static class EnableCachingConfig extends CachingConfigurerSupport {
|
||||
|
||||
@Resource
|
||||
CachingProvider cachingProvider;
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public org.springframework.cache.CacheManager cacheManager() {
|
||||
|
|
@ -80,7 +93,7 @@ public class JCacheEhCacheTests extends AbstractAnnotationTests {
|
|||
|
||||
@Bean
|
||||
public CacheManager jCacheManager() {
|
||||
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
|
||||
CacheManager cacheManager = this.cachingProvider.getCacheManager();
|
||||
MutableConfiguration<Object, Object> mutableConfiguration = new MutableConfiguration<Object, Object>();
|
||||
mutableConfiguration.setStoreByValue(false); // otherwise value has to be Serializable
|
||||
cacheManager.createCache("testCache", mutableConfiguration);
|
||||
|
|
|
|||
|
|
@ -16,12 +16,21 @@
|
|||
|
||||
package org.springframework.cache.jcache;
|
||||
|
||||
import javax.cache.Caching;
|
||||
import javax.cache.spi.CachingProvider;
|
||||
|
||||
/**
|
||||
* Just here to be run against EHCache 3, whereas the original JCacheEhCacheTests
|
||||
* runs against EhCache 2.x with the EhCache-JCache add-on.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @since 4.2.1
|
||||
*/
|
||||
public class JCacheEhCache3Tests extends JCacheEhCacheTests {
|
||||
|
||||
@Override
|
||||
protected CachingProvider getCachingProvider() {
|
||||
return Caching.getCachingProvider("org.ehcache.jsr107.EhcacheCachingProvider");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue