Search in sources :

Example 1 with ShardingJdbcDatabaseTester

use of io.shardingjdbc.core.common.env.ShardingJdbcDatabaseTester 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 2 with ShardingJdbcDatabaseTester

use of io.shardingjdbc.core.common.env.ShardingJdbcDatabaseTester 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)2 ShardingJdbcDatabaseTester (io.shardingjdbc.core.common.env.ShardingJdbcDatabaseTester)2 DatabaseType (io.shardingjdbc.core.constant.DatabaseType)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 IDatabaseTester (org.dbunit.IDatabaseTester)2 IDataSet (org.dbunit.dataset.IDataSet)2 FlatXmlDataSetBuilder (org.dbunit.dataset.xml.FlatXmlDataSetBuilder)2