public String evictEntityCacheCheck(String CACHE_REGION_NAME){
assertTrue("2lc entity cache is expected to contain Employee id = 20", emf.getCache().contains(Employee.class, 20));
assertTrue("2lc entity cache is expected to contain Employee id = 30", emf.getCache().contains(Employee.class, 30));
emf.getCache().evictAll();
EntityManager em = emf.createEntityManager();
Statistics stats = em.unwrap(Session.class).getSessionFactory().getStatistics();
stats.clear();
SecondLevelCacheStatistics emp2LCStats = stats.getSecondLevelCacheStatistics(CACHE_REGION_NAME+"Employee");
try{
assertEquals("Expected no entities stored in the cache"+emp2LCStats, 0, emp2LCStats.getElementCountInMemory());
assertFalse("2lc entity cache not expected to contain Employee id = 20", emf.getCache().contains(Employee.class, 20));
assertFalse("2lc entity cache not expected to contain Employee id = 30", emf.getCache().contains(Employee.class, 30));
Employee emp = getEmployee(em, 20);
assertNotNull("Employee returned", emp);
assertEquals("Expected 1 miss in 2LC"+generateEntityCacheStats(emp2LCStats), 1, emp2LCStats.getMissCount());
} finally{
em.close();
}
return "OK";
}