assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 1,
pageRecord.getPositionInFile());
assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 1,
btreePlusElementMgr.getLastRecordPositionInFile());
NonTerminalPage nonTerminalPage = new NonTerminalPage(1, true);
nonTerminalPage.setKey(0, new DataRecordIdentifier());
pageRecordable = nonTerminalPage;
pageRecordable.updateByteSize();
assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
pageRecord = pageRecordable.getPageRecord();
assertNotNull(MUST_BE_STORED, pageRecord);
assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 2,
pageRecord.getPositionInFile());
assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 2,
btreePlusElementMgr.getLastRecordPositionInFile());
btreePlusElementMgr.closeTransaction();
assertEquals("", PageConstant.PAGE_SIZE * 3, btreePlusElementMgr
.getFileForStorable().getFileSize());
btreePlusElementMgr.openTransaction();
final int numberOfKeyEntries = 1;
final DataRecordIdentifier[] keys = new DataRecordIdentifier[] { new DataRecordIdentifier(
0) };
final long[] pagePosition = new long[] { 0, 1 };
pageRecordable = new NonTerminalPage(numberOfKeyEntries, keys,
pagePosition, true);
assertNull(MUST_BE_NOT_STORED, pageRecordable.getPageRecord());
btreePlusElementMgr.appendPageRecordable(pageRecordable);
pageRecordable.setValueIsChangedValueToSave();
pageRecord = pageRecordable.getPageRecord();
assertNotNull(MUST_BE_STORED, pageRecord);
assertEquals(BAD_RECORD_POSITION, PageConstant.PAGE_SIZE * 3,
pageRecord.getPositionInFile());
assertEquals(BAD_LAST_RECORD_POSITION, PageConstant.PAGE_SIZE * 3,
btreePlusElementMgr.getLastRecordPositionInFile());
btreePlusElementMgr.closeTransaction();
assertEquals("", PageConstant.PAGE_SIZE * 4, btreePlusElementMgr
.getFileForStorable().getFileSize());
btreePlusElementMgr.openTransaction();
long position = PageConstant.PAGE_SIZE;
pageRecordable = btreePlusElementMgr.getPage(position, null, 0);
assertTrue("leaf page expected", pageRecordable instanceof LeafPage);
position += PageConstant.PAGE_SIZE;
pageRecordable = btreePlusElementMgr.getPage(position, null, 0);
assertTrue("non terminal page expected",
pageRecordable instanceof NonTerminalPage);
nonTerminalPage = (NonTerminalPage) pageRecordable;
assertEquals("bad non terminal page #1 state", 1,
nonTerminalPage.getNumberOfKeyEntries());
position += PageConstant.PAGE_SIZE;
pageRecordable = btreePlusElementMgr.getPage(position, null, 0);
assertTrue("non terminal page expected",
pageRecordable instanceof NonTerminalPage);
nonTerminalPage = (NonTerminalPage) pageRecordable;
assertEquals("bad non terminal page #2 state", 1,
nonTerminalPage.getNumberOfKeyEntries());
btreePlusElementMgr.closeTransactionDiscardChange();
}