}
public void testDataCacheOverFlow() {
OpenJPAEntityManagerSPI em = emf.createEntityManager();
StoreCacheImpl storeCache = (StoreCacheImpl) emf.getCache();
DataCache cache = (DataCache) storeCache.getDelegate();
LinkedList<CachedPerson> people = new LinkedList<CachedPerson>();
// Persist cacheSize + 1 Entites.
for (int i = 0; i < cacheSize + 1; i++) {
em.getTransaction().begin();
CachedPerson person = new CachedPerson();
person.setId(i);
em.persist(person);
people.addFirst(person);
em.getTransaction().commit();
}
// Assert that the first persisted entity isn't in the cache and everything else is.
for (int i = 0; i < cacheSize + 1; i++) {
IntId id = new IntId(CachedPerson.class, i);
boolean contains = cache.get(id) != null;
if (i == 0) {
assertFalse(contains);
} else {
assertTrue(contains);
}