Search in sources :

Example 1 with MockDBDriver

use of org.aion.db.impl.mockdb.MockDBDriver in project aion by aionnetwork.

the class MockDBDriverTest method setUp.

@Before
public void setUp() {
    vendor = DBVendor.MOCKDB;
    driver = new MockDBDriver();
    props = new Properties();
    props.setProperty("db_type", vendor.toValue());
    props.setProperty("db_name", "test");
    db = null;
}
Also used : MockDBDriver(org.aion.db.impl.mockdb.MockDBDriver) Properties(java.util.Properties) Before(org.junit.Before)

Example 2 with MockDBDriver

use of org.aion.db.impl.mockdb.MockDBDriver 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);
}
Also used : IByteArrayKeyValueDatabase(org.aion.base.db.IByteArrayKeyValueDatabase) MockDBDriver(org.aion.db.impl.mockdb.MockDBDriver) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

Properties (java.util.Properties)2 MockDBDriver (org.aion.db.impl.mockdb.MockDBDriver)2 IByteArrayKeyValueDatabase (org.aion.base.db.IByteArrayKeyValueDatabase)1 Before (org.junit.Before)1 Test (org.junit.Test)1