}
public void testDelete()
{
//*-- create an empty database
dbt = new DbTools(); dbt.openEnv(DBDIR, false);
assertTrue("t7 create", dbt.createDB(DBNAME2, true) );
dbt.closeEnv();
// *-- load a few rows
loadDB("t7", 10, false, DBNAME2);
//*-- fetch a document, delete the document and attempt to fetch it again
dbt = new DbTools(); dbt.openEnv(DBDIR, false);
assertTrue( "t7 open ", dbt.openDB(DBNAME2, false) );
String dbKey = "0000000002"; DatabaseEntry data = new DatabaseEntry();
assertTrue( "t7 fetch not successful", dbt.fetch(dbKey, data) );
data = new DatabaseEntry();
assertTrue("t7 delete failed", dbt.delete(dbKey) );
assertFalse( "t7 fetch should have failed", dbt.fetch(dbKey, data) );
dbt.closeDB(); dbt.closeEnv();
//*-- try to delete a non-existent row
dbt = new DbTools(); dbt.openEnv(DBDIR, false);
assertTrue( "t7 open ", dbt.openDB(DBNAME2, false) );
dbKey = "Bad key";
assertFalse("t7 this delete should fail", dbt.delete(dbKey) );
dbt.closeDB(); dbt.closeEnv();
//*-- drop the database
dbt = new DbTools(); dbt.openEnv(DBDIR, false);
assertTrue("t7 drop", dbt.dropDB(DBNAME2) );
dbt.closeEnv();
System.out.println("Completed delete document...");
}