*/
public void testGetFirstLast()
throws DatabaseException {
initEnv(true);
Locker txn = new BasicLocker(DbInternal.envGetEnvironmentImpl(env));
NullCursor cursor = new NullCursor(tree.getDatabase(), txn);
/* Make sure IllegalArgumentException is thrown for null args. */
try {
TestUtils.checkLatchCount();
tree.getFirstNode(null);
fail("Tree.getFirstNode didn't throw IllegalArgumentException");
} catch (IllegalArgumentException IAE) {
}
TestUtils.checkLatchCount();
try {
TestUtils.checkLatchCount();
tree.getLastNode(null);
fail("Tree.getLastNode didn't throw IllegalArgumentException");
} catch (IllegalArgumentException IAE) {
}
TestUtils.checkLatchCount();
byte[][] keys = new byte[N_TOP_LEVEL_KEYS][];
LN[][] lns = new LN[N_TOP_LEVEL_KEYS][];
byte[][] minKeys = new byte[N_TOP_LEVEL_KEYS][];
byte[][] maxKeys = new byte[N_TOP_LEVEL_KEYS][];
for (int i = 0; i < N_TOP_LEVEL_KEYS; i++) {
byte[] key = new byte[N_KEY_BYTES];
byte[] minKey = null;
byte[] maxKey = null;
keys[i] = key;
lns[i] = new LN[N_DUPLICATES_PER_KEY];
TestUtils.generateRandomAlphaBytes(key);
for (int j = 0; j < N_DUPLICATES_PER_KEY; j++) {
byte[] data = new byte[N_KEY_BYTES];
TestUtils.generateRandomAlphaBytes(data);
byte[] dupKey = data;
if (minKey == null) {
minKey = dupKey;
} else if (Key.compareKeys(dupKey, minKey) < 0) {
minKey = dupKey;
}
if (maxKey == null) {
maxKey = dupKey;
} else if (Key.compareKeys(maxKey, dupKey) < 0) {
maxKey = dupKey;
}
LN ln = new LN(data);
lns[i][j] = ln;
insertAndRetrieveDuplicate(key, ln, cursor);
}
minKeys[i] = minKey;
maxKeys[i] = maxKey;
}
for (int i = 0; i < N_TOP_LEVEL_KEYS; i++) {
byte[] key = keys[i];
for (int j = 0; j < N_DUPLICATES_PER_KEY; j++) {
validateFirstLast(key, minKeys[i], maxKeys[i]);
}
}
txn.operationEnd();
}