public void testTransactionExecution() throws Exception {
DatabaseManager dbMan = database.getDatabaseManager();
// create and execute a transaction
Transaction txn = dbMan.createTransaction();
txn.createDatabase("test", 3);
txn.insertRecord("test", 0, "hello".getBytes(), "world".getBytes());
txn.insertRecord("test", 1, "key".getBytes(), "value".getBytes());
dbMan.executeTransaction(txn);
// check if the database is there
Database db = dbMan.getDatabase("test");
assertNotNull(db);
assertEquals("test", db.getName());
assertEquals(3, 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));
// create and execute a second transaction
txn = dbMan.createTransaction();
txn.createDatabase("test2", 1);
txn.deleteRecord("test", 0, "hello".getBytes());
dbMan.executeTransaction(txn);
// check if the both databases are there
db = dbMan.getDatabase("test");
assertNotNull(db);
assertEquals("test", db.getName());
assertEquals(3, db.getComparators().length);
db = dbMan.getDatabase("test2");
assertNotNull(db);
assertEquals("test2", db.getName());
assertEquals(1, db.getComparators().length);
// check if the key got deleted
value = db.lookup(0, "hello".getBytes(), null).get();
assertNull(value);
// create and execute a third transaction
txn = dbMan.createTransaction();
txn.deleteDatabase("test");
txn.deleteDatabase("test2");
dbMan.executeTransaction(txn);
// check if all databases were deleted
assertEquals(0, dbMan.getDatabases().size());