use of com.alessiodp.core.common.storage.sql.connection.ConnectionFactory in project ADP-Core by AlessioDP.
the class MigratorTest method testEmptyDatabase.
@Test
public void testEmptyDatabase(@TempDir Path tempDir) throws IOException {
ConnectionFactory cf = getConnectionFactoryH2();
Handle handle = cf.getJdbi().open();
emptyDatabase(handle, cf.getJdbi().onDemand(SchemaHistoryH2Dao.class), prepareMigrator(cf, StorageType.H2));
handle.close();
cf = getConnectionFactorySQLite(tempDir);
handle = cf.getJdbi().open();
emptyDatabase(handle, cf.getJdbi().onDemand(SchemaHistorySQLiteDao.class), prepareMigrator(cf, StorageType.SQLITE));
handle.close();
cf = getConnectionFactoryMySQL();
if (cf != null) {
handle = cf.getJdbi().open();
handle.createUpdate("DROP TABLE IF EXISTS `<prefix>schema_history`, `<prefix>table`;").execute();
emptyDatabase(handle, cf.getJdbi().onDemand(SchemaHistoryMySQLDao.class), prepareMigrator(cf, StorageType.MYSQL));
handle.close();
}
cf = getConnectionFactoryMariaDB();
if (cf != null) {
handle = cf.getJdbi().open();
handle.createUpdate("DROP TABLE IF EXISTS `<prefix>schema_history`, `<prefix>table`;").execute();
emptyDatabase(handle, cf.getJdbi().onDemand(SchemaHistoryMariaDBDao.class), prepareMigrator(cf, StorageType.MARIADB));
handle.close();
}
cf = getConnectionFactoryPostgreSQL();
if (cf != null) {
handle = cf.getJdbi().open();
handle.createUpdate("DROP TABLE IF EXISTS <prefix>schema_history, <prefix>table;").execute();
emptyDatabase(handle, cf.getJdbi().onDemand(SchemaHistoryPostgreSQLDao.class), prepareMigrator(cf, StorageType.POSTGRESQL));
handle.close();
}
}
use of com.alessiodp.core.common.storage.sql.connection.ConnectionFactory in project ADP-Core by AlessioDP.
the class StorageTest method testCreate.
@Test
public void testCreate(@TempDir Path tempDir) throws IOException {
ConnectionFactory cf = MigratorTest.getConnectionFactoryH2();
create(cf.getJdbi().onDemand(SchemaHistoryH2Dao.class));
cf.stop();
cf = MigratorTest.getConnectionFactorySQLite(tempDir);
create(cf.getJdbi().onDemand(SchemaHistorySQLiteDao.class));
cf.stop();
}
use of com.alessiodp.core.common.storage.sql.connection.ConnectionFactory in project ADP-Core by AlessioDP.
the class StorageTest method testInsert.
@Test
public void testInsert(@TempDir Path tempDir) throws IOException {
ConnectionFactory cf = MigratorTest.getConnectionFactoryH2();
insert(cf.getJdbi().onDemand(SchemaHistoryH2Dao.class));
cf.stop();
cf = MigratorTest.getConnectionFactorySQLite(tempDir);
insert(cf.getJdbi().onDemand(SchemaHistorySQLiteDao.class));
cf.stop();
}
use of com.alessiodp.core.common.storage.sql.connection.ConnectionFactory in project Parties by AlessioDP.
the class SQLDispatcherTest method getSQLDispatcherH2.
private PartiesSQLDispatcher getSQLDispatcherH2() {
ConfigMain.STORAGE_SETTINGS_H2_DBFILE = "";
PartiesSQLDispatcher ret = new PartiesSQLDispatcher(mockPlugin, StorageType.H2) {
@Override
public ConnectionFactory initConnectionFactory() {
ConnectionFactory ret = super.initConnectionFactory();
ret.setDatabaseUrl("jdbc:h2:mem:" + UUID.randomUUID() + ";DB_CLOSE_DELAY=-1");
return ret;
}
};
ret.init();
return ret;
}
use of com.alessiodp.core.common.storage.sql.connection.ConnectionFactory in project Parties by AlessioDP.
the class SQLDispatcherTest method getSQLDispatcherSQLite.
private PartiesSQLDispatcher getSQLDispatcherSQLite(Path temporaryDirectory) {
ConfigMain.STORAGE_SETTINGS_SQLITE_DBFILE = "";
PartiesSQLDispatcher ret = new PartiesSQLDispatcher(mockPlugin, StorageType.SQLITE) {
@Override
public ConnectionFactory initConnectionFactory() {
ConnectionFactory ret = super.initConnectionFactory();
ret.setDatabaseUrl("jdbc:sqlite:" + temporaryDirectory.resolve("database.db"));
return ret;
}
};
ret.init();
return ret;
}
Aggregations