/* graph analyzing storage */
final ObjectIOManager objectIOManager = filePersistence
.getObjectIOManager();
final IHeapDataManager dataManager = filePersistence
.getDataManager();
referenceLinkGraphFromStorage = new ReferenceLinkGraph();
final Set<DataRecordIdentifier> forObjectDatarecordIdentifierSet = dataManager
.getDataRecordIdentifierSet();
forObjectDatarecordIdentifierSet
.remove(new DataRecordIdentifier(0));
Set<DataRecordIdentifier> setToUpdate = new TreeSet<DataRecordIdentifier>();
filePersistence.usedForGarbageManagement(setToUpdate);
filePersistence.usedForClassNameManagement(setToUpdate);
forObjectDatarecordIdentifierSet.removeAll(setToUpdate);
for (DataRecordIdentifier referencingDataRecordIdentifier : forObjectDatarecordIdentifierSet) {
final ObjectLinkTreeNode objectLinkTreeNode = objectIOManager
.getObjectLinkTreeNode(referencingDataRecordIdentifier);
final DataRecordIdentifier[] referencedList = objectLinkTreeNode
.getReferencedList();
referenceLinkGraphFromStorage.addReferenced(
referencingDataRecordIdentifier, referencedList);
}
/* graph from storage content */
referenceLinkGraphFromStorage
.compute(StoreForTest.IDENTIFIER_FOR_ROOT);
/* graph from link informations */
referenceLinkGraphFromLinkInfo = new ReferenceLinkGraph();
for (ReferenceLink referenceLink : referenceLinks) {
final DataRecordIdentifier referencedDataRecordIdentifier = referenceLink
.getReferencedDataRecordIdentifier();
TestCase.assertTrue("referenced not in storage", dataManager
.hasDataRecord(referencedDataRecordIdentifier));
final Collection<Referencing> referencings = referenceLink
.getReferencing();
for (Referencing referencing : referencings) {
final DataRecordIdentifier referencingDataRecordIdentifier = referencing
.getDataRecordIdentifier();
final int linkCount = referencing.getLinkCount();
referenceLinkGraphFromLinkInfo.addReferencing(
referencedDataRecordIdentifier,
referencingDataRecordIdentifier, linkCount);
}
}
referenceLinkGraphFromLinkInfo
.compute(StoreForTest.IDENTIFIER_FOR_ROOT);
TestCase.assertEquals(
referenceLinkGraphFromStorage.refMapToString(),
referenceLinkGraphFromLinkInfo.refMapToString());
//
for (DataRecordIdentifierRBTNode candidateNode : knownCandidate) {
final DataRecordIdentifier candidateDataRecordIdentifier = candidateNode
.getElement();
TestCase.assertTrue("candidate not in storage", dataManager
.hasDataRecord(candidateDataRecordIdentifier));
/* bad test below, because candidate can be attached to root */
// TestCase.assertFalse(
// "candidate can not be attached to root",
// referenceLinkGraphFromLinkInfo
// .isInAttachedToRootSet(candidateDataRecordIdentifier));
// assertNotNull("candidate must be in detached set",
// referenceLinkGraphFromLinkInfo
// .getDetachedToRootSet(candidate));
}
for (DataRecordIdentifierRBTNode toGrabageNode : knownToGarbage) {
final DataRecordIdentifier toGarbageDataRecordIdentifier = toGrabageNode
.getElement();
TestCase.assertTrue("to garbage not in storage", dataManager
.hasDataRecord(toGarbageDataRecordIdentifier));
TestCase.assertFalse(
"to garbage can not be attached to root",
referenceLinkGraphFromLinkInfo
.isInAttachedToRootSet(toGarbageDataRecordIdentifier));