Search in sources :

Example 6 with DatabaseEnvironment

use of io.shardingjdbc.core.common.env.DatabaseEnvironment in project sharding-jdbc by shardingjdbc.

the class AbstractSQLAssertTest method importAllDataSet.

protected static void importAllDataSet(final List<String> dataSetFiles) throws Exception {
    for (DatabaseType databaseType : getDatabaseTypes()) {
        DatabaseEnvironment dbEnv = new DatabaseEnvironment(databaseType);
        for (String each : dataSetFiles) {
            InputStream is = AbstractSQLTest.class.getClassLoader().getResourceAsStream(each);
            IDataSet dataSet = new FlatXmlDataSetBuilder().build(new InputStreamReader(is));
            IDatabaseTester databaseTester = new ShardingJdbcDatabaseTester(dbEnv.getDriverClassName(), dbEnv.getURL(getDatabaseName(each)), dbEnv.getUsername(), dbEnv.getPassword(), dbEnv.getSchema(getDatabaseName(each)));
            databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
            databaseTester.setDataSet(dataSet);
            databaseTester.onSetup();
        }
    }
}
Also used : DatabaseEnvironment(io.shardingjdbc.core.common.env.DatabaseEnvironment) DatabaseType(io.shardingjdbc.core.constant.DatabaseType) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IDatabaseTester(org.dbunit.IDatabaseTester) IDataSet(org.dbunit.dataset.IDataSet) FlatXmlDataSetBuilder(org.dbunit.dataset.xml.FlatXmlDataSetBuilder) ShardingJdbcDatabaseTester(io.shardingjdbc.core.common.env.ShardingJdbcDatabaseTester)

Example 7 with DatabaseEnvironment

use of io.shardingjdbc.core.common.env.DatabaseEnvironment in project sharding-jdbc by shardingjdbc.

the class AbstractSQLTest method importDataSet.

protected final void importDataSet() throws Exception {
    for (DatabaseType databaseType : getDatabaseTypes()) {
        if (databaseType == getCurrentDatabaseType() || null == getCurrentDatabaseType()) {
            DatabaseEnvironment dbEnv = new DatabaseEnvironment(databaseType);
            for (String each : getInitDataSetFiles()) {
                InputStream is = AbstractSQLTest.class.getClassLoader().getResourceAsStream(each);
                IDataSet dataSet = new FlatXmlDataSetBuilder().build(new InputStreamReader(is));
                IDatabaseTester databaseTester = new ShardingJdbcDatabaseTester(dbEnv.getDriverClassName(), dbEnv.getURL(getDatabaseName(each)), dbEnv.getUsername(), dbEnv.getPassword(), dbEnv.getSchema(getDatabaseName(each)));
                databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
                databaseTester.setDataSet(dataSet);
                databaseTester.onSetup();
            }
        }
    }
}
Also used : DatabaseEnvironment(io.shardingjdbc.core.common.env.DatabaseEnvironment) DatabaseType(io.shardingjdbc.core.constant.DatabaseType) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IDatabaseTester(org.dbunit.IDatabaseTester) IDataSet(org.dbunit.dataset.IDataSet) FlatXmlDataSetBuilder(org.dbunit.dataset.xml.FlatXmlDataSetBuilder) ShardingJdbcDatabaseTester(io.shardingjdbc.core.common.env.ShardingJdbcDatabaseTester)

Aggregations

DatabaseEnvironment (io.shardingjdbc.core.common.env.DatabaseEnvironment)7 FlatXmlDataSetBuilder (org.dbunit.dataset.xml.FlatXmlDataSetBuilder)6 Connection (java.sql.Connection)4 ITable (org.dbunit.dataset.ITable)4 InputStreamReader (java.io.InputStreamReader)3 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)3 IDataSet (org.dbunit.dataset.IDataSet)3 ShardingJdbcDatabaseTester (io.shardingjdbc.core.common.env.ShardingJdbcDatabaseTester)2 DatabaseType (io.shardingjdbc.core.constant.DatabaseType)2 InputStream (java.io.InputStream)2 PreparedStatement (java.sql.PreparedStatement)2 IDatabaseTester (org.dbunit.IDatabaseTester)2 ReplacementDataSet (org.dbunit.dataset.ReplacementDataSet)2 BasicDataSource (org.apache.commons.dbcp2.BasicDataSource)1 ITableIterator (org.dbunit.dataset.ITableIterator)1