StoreNotSerializableException, StoreClassNotFoundException,
StoreDataCorruptedException, ProxyException, SecurityException,
NoSuchFieldException, IllegalArgumentException,
IllegalAccessException, ObjectIOException,
ObjectIOInvalidClassException, StoreTooBigForSerializationException {
Bob1 rootBob1 = new Bob1();
storeForTest.setRoot(rootBob1);
rootBob1.setBob1(new Bob1());
// use storeForTest.newInstance(Bob2.class) because rootBob1 will be
// never unreferenced
// Bob2 bob2RefByRootBob1 = new Bob2();
Bob2 bob2RefByRootBob1 = (Bob2) storeForTest.newInstance(Bob2.class);
Bob3 bob3RefByBob2RefByRootBob1 = new Bob3();
bob2RefByRootBob1.setBob3(bob3RefByBob2RefByRootBob1);
rootBob1.setBob2(bob2RefByRootBob1);
rootBob1.setBob3(new Bob3());
rootBob1 = null;// NOPMD want to unreference
// save not for close
storeForTest.save(false, false);
final ObjectAndPersistInfo opiBob3 = storeForTest
.getObjectAndPersistInfoOfObjectFromQueue(bob3RefByBob2RefByRootBob1);
assertTrue("must be weaked", opiBob3.isWeak());
bob2RefByRootBob1 = null;// NOPMD want to unreference
rootBob1 = null;// NOPMD want to unreference
bob3RefByBob2RefByRootBob1 = null;// NOPMD want to unreference
storeForTest.save(false, false);
assertTrue("must be weaked", opiBob3.isWeak());
MemoryEater.useAllMemoryThenRelease();
assertTrue("must be free", opiBob3.hasNoReferences());
rootBob1 = (Bob1) storeForTest.readAndGetRoot();
assertNotNull("must be set", rootBob1.getBob1());// NOPMD
bob2RefByRootBob1 = rootBob1.getBob2();
assertNotNull("must be set", bob2RefByRootBob1);
assertNotNull("must be set", rootBob1.getBob3());
// not below assert because load bob2RefByRootBob1
// assertNotNull("must be set", bob2RefByRootBob1.getBob3());
// test can not work with bob1 because read of root record
// assertTrue("must be a proxy: "+bob1.getClass(),