final byte bits) throws HeapException {
long position = context.getPosition();
byte contentValue = 0;
int index = 0;
long nextFreeDataBlockPosition;
DataBlock dataBlock = createDataBlock(bits, contentValue);
context.addDataBlock(dataBlock, contentValue);
final DataBlockPage dataBlockPage = dataBlock.getDataBlockPage();
do {
final long dataBlockPosition = dataBlock.getPositionInFile();
assertEquals("data block not in expected page (bits " + bits
+ ", contentValue " + contentValue + ")", position,
dataBlockPosition & PageConstant.START_PAGE_POSITION_MASK);
assertEquals("bad index", index,
dataBlock.getIndexInDataBlockPage());
nextFreeDataBlockPosition = getHeapHeader().getFirstFreeBlock(bits);
if (nextFreeDataBlockPosition != -1L) {
contentValue++;
index++;
dataBlock = createDataBlock(bits, contentValue);
assertSame("bad data block page", dataBlockPage,
dataBlock.getDataBlockPage());
}
} while (nextFreeDataBlockPosition != -1L);
final int numberOfBlockCreated = index + 1;
assertEquals("number of block missmatch", numberOfBlockCreated,
dataBlockPage.getNumberOfBlock());