public void test() throws StoreException, GarbageException,
StoreInvalidClassException, StoreNotSerializableException,
StoreClassNotFoundException, StoreDataCorruptedException,
ReferenceLinkGarbageException, StoreTooBigForSerializationException {
Bob1 bob1 = new Bob1();
store.setRoot(bob1);
store.save(true, false);
bob1 = (Bob1) store.readAndGetRoot();
DataRecordIdentifier dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);
if (logger.debugEnabled) {
logger.debug("data record if of bob1 is "
+ dataRecordIdentifierForBob1);
}
/* check only StoreRoot referencing bob1 */
assertReferencing(dataRecordIdentifierForBob1,
new DataRecordIdentifier[] { StoreForTest.IDENTIFIER_FOR_ROOT });
/* add bob1 --> bob2 */
Bob2 bob2 = new Bob2();
bob1.setBob2(bob2);
store.save(true, false);
/* check bob1 --> bob2 */
assertRef1();
/* add bob1 --> bob3 */
bob1 = (Bob1) store.readAndGetRoot();
Bob3 bob3 = new Bob3();
bob1.setBob3(bob3);
store.save(true, false);
/* check bob1 --> bob2, bob1 --> bob3 */
assertRef2();
/* add bob2 --> bob1 */
bob1 = (Bob1) store.readAndGetRoot();
bob2 = bob1.getBob2();
bob2.setBob1(bob1);
store.save(true, false);
/* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1 */
assertRef3();
/* add bob2 --> bob3 */
bob1 = (Bob1) store.readAndGetRoot();
bob2 = bob1.getBob2();
bob3 = bob1.getBob3();
bob2.setBob3(bob3);
store.save(true, false);
/* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1,bob2 --> bob3 */
assertRef4();
/* add bob3 --> bob1 */
bob1 = (Bob1) store.readAndGetRoot();
bob3 = bob1.getBob3();
bob3.setBob1(bob1);
store.save(true, false);
/*
* check bob1 --> bob2, bob1 --> bob3, bob2 --> bob1, bob2 --> bob3,
* bob3 --> bob1
*/
assertRef5();
/* add bob3 --> bob2 */
bob1 = (Bob1) store.readAndGetRoot();
bob2 = bob1.getBob2();
bob3 = bob1.getBob3();
bob3.setBob2(bob2);
store.save(true, false);
/*
* check bob1 --> bob2, bob1 --> bob3, bob2 --> bob1, bob2 --> bob3,
* bob3 --> bob1, bob3 --> bob2
*/
assertRef6();
/* remove bob3 --> bob2 */
bob1 = (Bob1) store.readAndGetRoot();
bob3 = bob1.getBob3();
bob3.setBob2(null);
store.save(true, false);
/*
* check bob1 --> bob2, bob1 --> bob3, bob2 --> bob1, bob2 --> bob3,
* bob3 --> bob1
*/
assertRef5();
/* remove bob3 --> bob1 */
bob1 = (Bob1) store.readAndGetRoot();
bob3 = bob1.getBob3();
bob3.setBob1(null);
store.save(true, false);
/* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1,bob2 --> bob3 */
assertRef4();
/* remove bob2 --> bob3 */
bob1 = (Bob1) store.readAndGetRoot();
bob2 = bob1.getBob2();
bob2.setBob3(null);
store.save(true, false);
/* check bob1 --> bob2, bob1 --> bob3,bob2 --> bob1 */
assertRef3();
/* remove bob2 --> bob1 */
bob1 = (Bob1) store.readAndGetRoot();
bob2 = bob1.getBob2();
bob2.setBob1(null);
store.save(true, false);
/* check bob1 --> bob2, bob1 --> bob3 */
assertRef2();
/* remove bob1 --> bob3 */
bob1 = (Bob1) store.readAndGetRoot();
bob1.setBob3(null);
store.save(true, false);
/* check bob1 --> bob2 */
assertRef1();
/* remove bob1 --> bob2 */
bob1 = (Bob1) store.readAndGetRoot();
bob1.setBob2(null);
store.save(true, false);
bob1 = (Bob1) store.readAndGetRoot();
dataRecordIdentifierForBob1 = getDataRecordIdentifier(bob1);