@Test
public void testReplayAfterCrash() throws Exception {
database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 1, 0, 0,
SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL));
Database db = database.getDatabaseManager().createDatabase("test", 2);
db.singleInsert(0, "Yagga".getBytes(), "Brabbel".getBytes(), null).get();
database.getCheckpointer().checkpoint();
byte[] result = db.lookup(0, "Yagga".getBytes(), null).get();
String value = new String(result);
assertEquals(value, "Brabbel");
db.singleInsert(0, "Brabbel".getBytes(), "Blupp".getBytes(), null).get();
result = db.lookup(0, "Brabbel".getBytes(), null).get();
value = new String(result);
assertEquals(value, "Blupp");
db.singleInsert(0, "Blupp".getBytes(), "Blahh".getBytes(), null).get();
result = db.lookup(0, "Blupp".getBytes(), null).get();
value = new String(result);
assertEquals(value, "Blahh");
((BabuDBImpl) database).__test_killDB_dangerous();
Thread.sleep(500);
database = BabuDBFactory.createBabuDB(new BabuDBConfig(baseDir, baseDir, 2, 0, 0,
SyncMode.SYNC_WRITE, 0, 0, COMPRESSION, maxNumRecs, maxBlockFileSize, !MMAP, -1, LOG_LEVEL));
db = database.getDatabaseManager().getDatabase("test");
result = db.lookup(0, "Yagga".getBytes(), null).get();
assertNotNull(result);
value = new String(result);
assertEquals(value, "Brabbel");
result = db.lookup(0, "Brabbel".getBytes(), null).get();
assertNotNull(result);
value = new String(result);
assertEquals(value, "Blupp");
result = db.lookup(0, "Blupp".getBytes(), null).get();
assertNotNull(result);
value = new String(result);
assertEquals(value, "Blahh");
System.out.println("shutting down database...");