ehCache - Neethahiremath/Wiki GitHub Wiki
if you want to test EhCache:
private Cache animalCache;
and can add @TestInstance(TestInstance.Lifecycle.PER_CLASS) at class level
@BeforeAll
void initialSetUp() {
animalCache = getAnimalCache();
animals = Stream.of("2806").collect(Collectors.toSet());
}
private Cache getAnimalCache() {
net.sf.ehcache.CacheManager cacheManager = new net.sf.ehcache.CacheManager();
cacheManager.addCache("animal");
org.springframework.cache.CacheManager cacheManager1 = new EhCacheCacheManager(cacheManager);
Cache cache = cacheManager1.getCache("animal");
cache.put("2806", getAnimalEntity());
return cache;
}
private AnimalEntity getAnimalEntity() {
AnimalEntity animalEntity = new AnimalEntity();
animalEntity.setAnimal("dog");
return animalEntity;
}