Skip to content

Instantly share code, notes, and snippets.

@doubleirish
Created May 19, 2015 23:50
Show Gist options
  • Save doubleirish/713001237292fff96079 to your computer and use it in GitHub Desktop.
Save doubleirish/713001237292fff96079 to your computer and use it in GitHub Desktop.
No Hits on my L2 Cache ?
@RunWith(SpringJUnit4ClassRunner.class)
@TransactionConfiguration(transactionManager = "txManager", defaultRollback = true)
...
public class BookDaoTest extends AbstractTransactionalJUnit4SpringContextTests {
@Test public void testBookEntityCaching() {
bookDao.findById(3);
bookDao.findById(3);
Statistics stats = bookDao.getHibernateStatistics();
String regionName = "edu.uw.data.model.Book";
SecondLevelCacheStatistics level2BookEntityStats =
stats.getSecondLevelCacheStatistics(regionName);
assertNotNull("missing ehcache region or @Cache ",level2BookEntityStats);
assertThat(level2BookEntityStats.getHitCount(), Is.is(greaterThan(0L)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment