FilePersistenceClassNotFoundException,
FilePersistenceDataCorruptedException, ProxyException,
FilePersistenceTooBigForSerializationException, ObjectIOException,
InterruptedException {
session.open();
Bob1 bob1 = new Bob1();
saveDoneFlag = false;
session.setObject(KEY, bob1);
assertTrue(MUST_SAVE, saveDoneFlag);
// bob1 = null;// NOPMD release/unreference the object
session.save(); // to clear bob1 persistence state
final ObjectAndPersistInfo opiBob1 = filePersistence
.getObjectAndPersistInfoOfObjectFromQueue(bob1);
bob1 = null;// NOPMD release/unreference the object
session.save(); // to clear bob1 persistence state
// useMemory(opiBob1);
MemoryEater.useAllMemoryThenRelease();
assertTrue("must be free", opiBob1.hasNoReferences());
saveDoneFlag = false;
bob1 = (Bob1) session.getObject(KEY);
assertTrue(MUST_SAVE, saveDoneFlag);
assertNotNull("must retrieve bob1", bob1);
saveDoneFlag = false;
assertTrue("must be a proxy", ProxyManager2.isProxyOrEnhanced(bob1));
assertFalse("must not be loaded",
ProxyManager2.proxiedObjectIsLoaded(bob1));
assertFalse("must not change", saveDoneFlag);// check proxy manager not
// alter state
bob1.setBob2(new Bob2());// must trigger auto save
assertTrue(MUST_SAVE, saveDoneFlag);
// assert not loaded, not loaded because of auto save
assertFalse("must not be loaded",
ProxyManager2.proxiedObjectIsLoaded(bob1));
Bob2 bob2 = bob1.getBob2();
assertFalse("must not be a proxy " + bob2.toString(),
ProxyManager2.isProxyOrEnhanced(bob2));
// bob2 = null;// NOPMD
/* save to erase bob2 persistence state => bob2 no more referenced */
session.save();
final ObjectAndPersistInfo opiBob2 = filePersistence
.getObjectAndPersistInfoOfObjectFromQueue(bob2);
bob2 = null;// NOPMD
session.save();
// useMemory(opiBob2);
MemoryEater.useAllMemoryThenRelease();
assertTrue("must be free", opiBob2.hasNoReferences());
bob2 = bob1.getBob2();
assertTrue("must be a proxy", ProxyManager2.isProxyOrEnhanced(bob2));
session.close();
}