Ehcache shutdown causing an exception while running test suite
Make a seperate cache config for tests only! and put scope "prototype"
@Configuration
@EnableCaching
public class EhCacheConfig {
@Bean(name = "cacheManager")
@Scope("prototype")
public CacheManager getCacheManager() {
return new EhCacheCacheManager(getEhCacheFactory().getObject());
}
@Bean
@Scope("prototype")
public EhCacheManagerFactoryBean getEhCacheFactory() {
EhCacheManagerFactoryBean factoryBean = new EhCacheManagerFactoryBean();
factoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
factoryBean.setShared(true);
return factoryBean;
}
}
try to set shared property to false in EhCacheManagerFactoryBean
or EhCacheCacheManager
in the testing context.