/* Open db. */
initEnv(false);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
Database myDb = exampleEnv.openDatabase(null, "fooDb", dbConfig);
/* Open uninitialized cursor. */
Cursor c1 = myDb.openCursor(null, null);
try {
c1.getCurrent(new DatabaseEntry(), new DatabaseEntry(), null);
fail();
} catch (DatabaseException expected) {}
/* Dup uninitialized cursor with samePosition=false. */
Cursor c2 = c1.dup(false);
try {
c2.getCurrent(new DatabaseEntry(), new DatabaseEntry(), null);
fail();
} catch (DatabaseException expected) {}
/* Dup uninitialized cursor with samePosition=true. */
Cursor c3 = c1.dup(true);
try {
c3.getCurrent(new DatabaseEntry(), new DatabaseEntry(), null);
fail();
} catch (DatabaseException expected) {}
/* Ensure dup'ed cursors are usable. */
assertEquals(OperationStatus.SUCCESS,
c1.put(new DatabaseEntry(new byte[0]),
new DatabaseEntry(new byte[0])));
assertEquals(OperationStatus.SUCCESS,
c2.getFirst(new DatabaseEntry(), new DatabaseEntry(),
null));
assertEquals(OperationStatus.NOTFOUND,
c2.getNext(new DatabaseEntry(), new DatabaseEntry(),
null));
assertEquals(OperationStatus.SUCCESS,
c3.getFirst(new DatabaseEntry(), new DatabaseEntry(),
null));
assertEquals(OperationStatus.NOTFOUND,
c3.getNext(new DatabaseEntry(), new DatabaseEntry(),
null));
/* Close db. */
c3.close();
c2.close();
c1.close();
myDb.close();
}