}
@Test
public void testTransactionPersistence() throws Exception {
DatabaseManager dbMan = database.getDatabaseManager();
// create and execute a transaction
Transaction txn = dbMan.createTransaction();
txn.createDatabase("test", 2);
txn.insertRecord("test", 0, "hello".getBytes(), "world".getBytes());
txn.insertRecord("test", 1, "key".getBytes(), "value".getBytes());
dbMan.executeTransaction(txn);
// shutdown and restart the database
database.shutdown();
database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0, SyncMode.ASYNC, 0,
0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL));
// retrieve the dbMan of the restarted BabuDB
dbMan = database.getDatabaseManager();
// check if the database is there
Database db = dbMan.getDatabase("test");
assertNotNull(db);
assertEquals("test", db.getName());
assertEquals(2, db.getComparators().length);
// check if the records are there
byte[] value = db.lookup(0, "hello".getBytes(), null).get();
assertEquals("world", new String(value));
value = db.lookup(1, "key".getBytes(), null).get();
assertEquals("value", new String(value));
// enforce a checkpoint
database.getCheckpointer().checkpoint();
// shutdown and restart the database
database.shutdown();
database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 0, 0, 0, SyncMode.ASYNC, 0,
0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL));
// retrieve the dbMan of the restarted BabuDB
dbMan = database.getDatabaseManager();
// check if the database is there
db = dbMan.getDatabase("test");
assertNotNull(db);
assertEquals("test", db.getName());
assertEquals(2, db.getComparators().length);
// check if the records are there