ObjectIODataCorruptedException, ObjectIONotSerializableException,
StoreTooBigForSerializationException {
/*
* creation of object graph with a cycle
*/
BobContainer bobContainer = new BobContainer();
Bob1 bob1 = new Bob1();
bobContainer.setObject1(bob1);
Bob2 bob2 = new Bob2();
bob1.setBob2(bob2);
Bob3 bob3 = new Bob3();
bob2.setBob3(bob3);
bob3.setBob1(bob1);
store.setRoot(bobContainer);
logger.debug("initial save");
store.save(false, false);
Map<DataRecordIdentifier, String> map = objectClassMap(new DataRecordIdentifier[] {});
objectIoManager.clearObjectState();
final String links1 = links(map);
// logAllDataIdentifier();
// objectIoManager.clearObjectState();
// heapRecordableManager.clear();
/*
* assert garbage information after initial creation
*/
String expectedLinks = sortString(
/**/"StoreRoot4 -> BobContainer\n" +
/**/"BobContainer -> Bob1\n" +
/**/"Bob1 -> Bob2\n" +
/**/"Bob2 -> Bob3\n" +
/**/"Bob3 -> Bob1\n");
assertEquals("not expected link", expectedLinks, links1);
int numberToGarbage = toGarbageRecordManager.getNumberOfToGarbage();
assertEquals("must not have object to garbage", 0, numberToGarbage);
int numberOfGarbageCandidate = garbageCandidateRecordManager
.getNumberOfGarbageCandidate();
assertEquals(MUST_NOT_HAVE_OBJECT_MARKED_GARBAGE_CANDIDATE, 0,
numberOfGarbageCandidate);
final int initialNumberOfDataRecord = dataManager
.getNumberOfDataRecord();
/*
* read, check data record identifier, detach object, save
*/
bobContainer = (BobContainer) store.readAndGetRoot();
final DataRecordIdentifier idBobContainer = store
.getDataRecordIdentifierAssociatedToObject(bobContainer);
logger.debug("id bob container " + idBobContainer);
assertNotNull("bobContainer must have associated data record",
idBobContainer);
bob1 = (Bob1) bobContainer.getObject1();
final DataRecordIdentifier idBob1 = store
.getDataRecordIdentifierAssociatedToObject(bob1);
logger.debug("id bob1 " + idBob1);
assertNotNull("bob1 must have associated data record", idBob1);
bob2 = bob1.getBob2();
final DataRecordIdentifier idBob2 = store
.getDataRecordIdentifierAssociatedToObject(bob2);
logger.debug("id bob2 " + idBob2);
assertNotNull("bob2 must have associated data record", idBob2);
bob3 = bob2.getBob3();
final DataRecordIdentifier idBob3 = store
.getDataRecordIdentifierAssociatedToObject(bob3);
logger.debug("id bob3 " + idBob3);
assertNotNull("bob3 must have associated data record", idBob3);
assertDataRecord(new DataRecordIdentifier[] {
/**/StoreForTest.IDENTIFIER_FOR_STORE_HEADER,/* store header */
/**/StoreForTest.IDENTIFIER_FOR_ROOT,/* root record */
/**/idBobContainer,/**/
/**/idBob1,/**/
/**/idBob2,/**/
/**/idBob3 /**/
}, new DataRecordIdentifier[] {});
/* bob1 must be garbage candidate */
bobContainer.setObject1(null);
store.save(false, false);
// logAllDataIdentifier();
map = objectClassMap(new DataRecordIdentifier[] { idBob1 });
objectIoManager.clearObjectState();
final String links2 = links(map);