public void testInsertNullValue()
{
File tmpFile = FileSupport.createTempFile();
try
{
ReadWritableFile f = new ReadWritableFileAdapter(tmpFile);
byte[] barr = writeJunk(f);
// A tree that should support null values.
BPlusTree<Long, Long> btr = new BPlusTree<Long, Long>(new FileBackedNodeRepository<Long, Long>(f, false, f.getSize(), new NumberOfRecordsNodeSizeStrategy(2), false, LongNullSerializer.INSTANCE, LongNullSerializer.INSTANCE, 8, 8192, null, new LogAdapterHolder(new StdOutLogAdapter())), new LogAdapterHolder(new StdOutLogAdapter()));
try
{
btr.insert(12L, null);
assertNull(btr.find(12L));
assertTrue(btr.containsKey(12L));
assertEquals(12L, btr.findRecord(12L, SearchMode.EXACT_MATCH).getKey().longValue());
btr.delete(12L);
}
finally
{
btr.close();
}
assertJunkUntouched(f, barr);
}
finally
{
assertTrue(tmpFile.delete());
}
tmpFile = FileSupport.createTempFile();
try
{
ReadWritableFile f = new ReadWritableFileAdapter(tmpFile);
byte[] barr = writeJunk(f);
// A tree that does not support null values
BPlusTree<Long, Long> btr = new BPlusTree<Long, Long>(new FileBackedNodeRepository<Long, Long>(f, false, f.getSize(), new NumberOfRecordsNodeSizeStrategy(2), false, LongNullSerializer.INSTANCE, LongSerializer.INSTANCE, 8, 8192, null, new LogAdapterHolder(new StdOutLogAdapter())), new LogAdapterHolder(new StdOutLogAdapter()));
try
{
btr.insert(Long.valueOf(12L), null);
fail();
}