public void testStoreRestore() throws Exception {// NOPMD
/*
* data record
*/
HeapRecord heapRecord = new HeapRecord(
/**/this/*
* IHeapElementManager heapElementManager
*/,
/**/0/* long positionInFile */,
/**/1L/* long previousRecordPositionInFile */,
/**/DataRecordIdentifier.ZERO/* long nodeIdentification */,
/**/false/* boolean freeRecord */,
/**/10/* int dataAssociatedSize */,
/**/100/* int areaSize */);
final HeapIdNode heapIdNode = (HeapIdNode) heapRecord.getIdNode();
heapIdNode.setLeftPositionInFile(2);
heapIdNode.setRightPositionInFile(3);
heapIdNode.setParentPositionInFile(4);
try {
heapIdNode.setBlack();
} catch (Exception exception) {
// ignore error
}
// byte[] data = heapRecord.getDataAssociated();
final byte[] data = new byte[10];
heapRecord.setDataAssociated(data);
System.arraycopy("0123456789".getBytes(), 0, data, 0, 10);
heapRecord.setValueIsChangedValueToSave();
heapRecord.writeToFile();
readAndCheck(heapRecord, data);
/*
* free record
*/
heapRecord = new HeapRecord(
/**/this/*
* IHeapElementManager heapElementManager
*/,
/**/0/* long positionInFile */,
/**/90L/* long previousRecordPositionInFile */,
/**/DataRecordIdentifier.ZERO/* long nodeIdentification */,
/**/true/* boolean freeRecord */,
/**/0/* int dataAssociatedSize */,
/**/100/* int areaSize */);
final HeapFreeNode heapFreeNode = (HeapFreeNode) heapRecord
.getFreeNode();
heapFreeNode.setLeftPositionInFile(91);
heapFreeNode.setRightPositionInFile(92);
heapFreeNode.setParentPositionInFile(93);
try {
heapFreeNode.setBlack();
} catch (Exception exception) {
// ignore error
}
// to force write
heapRecord.setValueIsChangedValueToSave();
heapRecord.writeToFile();
readAndCheck(heapRecord, null);
}