use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testKeysWithClosedDatabase.
@Test(expected = RuntimeException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testKeysWithClosedDatabase(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.isOpen()).isFalse();
// attempt keys on closed db
db.keys();
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testIsEmptyWithClosedDatabase.
@Test(expected = RuntimeException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testIsEmptyWithClosedDatabase(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.isOpen()).isFalse();
// attempt isEmpty on closed db
db.isEmpty();
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testDeleteWithNullKey.
@Test(expected = IllegalArgumentException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testDeleteWithNullKey(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.open()).isTrue();
// attempt delete with null key
db.delete(null);
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testSizeWithClosedDatabase.
@Test(expected = RuntimeException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testSizeWithClosedDatabase(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.isOpen()).isFalse();
// attempt approximateSize on closed db
db.approximateSize();
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class DatabaseFactoryTest method testDriverReturnDatabase.
// It should return an instance of the DB given the correct properties
@Test
public void testDriverReturnDatabase() {
Properties props = new Properties();
props.setProperty("db_name", dbName + DatabaseTestUtils.getNext());
props.setProperty("db_path", dbPath);
// MOCKDB
props.setProperty("db_type", DBVendor.MOCKDB.toValue());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(props);
// System.out.println(db.getClass().getName());
assertNotNull(db);
// LEVELDB
props.setProperty("db_type", DBVendor.LEVELDB.toValue());
props.setProperty(DatabaseFactory.PROP_MAX_FD_ALLOC, String.valueOf(LevelDBConstants.MAX_OPEN_FILES));
props.setProperty(DatabaseFactory.PROP_BLOCK_SIZE, String.valueOf(LevelDBConstants.BLOCK_SIZE));
props.setProperty(DatabaseFactory.PROP_WRITE_BUFFER_SIZE, String.valueOf(LevelDBConstants.WRITE_BUFFER_SIZE));
props.setProperty(DatabaseFactory.PROP_CACHE_SIZE, String.valueOf(LevelDBConstants.CACHE_SIZE));
db = DatabaseFactory.connect(props);
// System.out.println(db.getClass().getName());
assertNotNull(db);
// H2
props.setProperty("db_type", DBVendor.H2.toValue());
db = DatabaseFactory.connect(props);
// System.out.println(db.getClass().getName());
assertNotNull(db);
// MockDBDriver class
props.setProperty("db_type", MockDBDriver.class.getName());
db = DatabaseFactory.connect(props);
// System.out.println(db.getClass().getName());
assertNotNull(db);
}
Aggregations