use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testPutBatchWithClosedDatabase.
@Test(expected = RuntimeException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testPutBatchWithClosedDatabase(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.isOpen()).isFalse();
Map<byte[], byte[]> map = new HashMap<>();
map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
// attempt putBatch on closed db
db.putBatch(map);
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testPutWithNullKey.
@Test(expected = IllegalArgumentException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testPutWithNullKey(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.open()).isTrue();
// attempt put with null key
db.put(null, DatabaseTestUtils.randomBytes(32));
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testDeleteWithClosedDatabase.
@Test(expected = RuntimeException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testDeleteWithClosedDatabase(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.isOpen()).isFalse();
// attempt delete on closed db
db.delete(DatabaseTestUtils.randomBytes(32));
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testPutBatchWithNullKey.
@Test(expected = IllegalArgumentException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testPutBatchWithNullKey(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.open()).isTrue();
Map<byte[], byte[]> map = new HashMap<>();
map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
map.put(DatabaseTestUtils.randomBytes(32), DatabaseTestUtils.randomBytes(32));
map.put(null, DatabaseTestUtils.randomBytes(32));
// attempt putBatch on closed db
db.putBatch(map);
}
use of org.aion.base.db.IByteArrayKeyValueDatabase in project aion by aionnetwork.
the class AccessWithExceptionTest method testDeleteBatchWithNullKey.
@Test(expected = IllegalArgumentException.class)
@Parameters(method = "databaseInstanceDefinitions")
public void testDeleteBatchWithNullKey(Properties dbDef) {
// create database
dbDef.setProperty("db_name", DatabaseTestUtils.dbName + DatabaseTestUtils.getNext());
IByteArrayKeyValueDatabase db = DatabaseFactory.connect(dbDef);
assertThat(db.open()).isTrue();
List<byte[]> list = new ArrayList<>();
list.add(DatabaseTestUtils.randomBytes(32));
list.add(DatabaseTestUtils.randomBytes(32));
list.add(null);
// attempt deleteBatch on closed db
db.deleteBatch(list);
}
Aggregations