use of org.dbunit.dataset.IDataSet 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();
}
}
}
use of org.dbunit.dataset.IDataSet 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();
}
}
}
}
use of org.dbunit.dataset.IDataSet in project SSM by Intel-bigdata.
the class TestAccessCountTableManager method initTestEnvironment.
private AccessCountTableManager initTestEnvironment() throws Exception {
MetaStore metaStore = new MetaStore(druidPool);
createTables(databaseTester.getConnection().getConnection());
IDataSet dataSet = new XmlDataSet(getClass().getClassLoader().getResourceAsStream("files.xml"));
databaseTester.setDataSet(dataSet);
databaseTester.onSetup();
prepareFiles(metaStore);
return new AccessCountTableManager(metaStore);
}
use of org.dbunit.dataset.IDataSet in project SSM by Intel-bigdata.
the class TestTableAggregator method testGetTopN.
@Test
public void testGetTopN() throws Exception {
createTables(databaseTester.getConnection());
IDataSet dataSet = new XmlDataSet(getClass().getClassLoader().getResourceAsStream("accessCountTable.xml"));
databaseTester.setDataSet(dataSet);
databaseTester.onSetup();
MetaStore metaStore = new MetaStore(druidPool);
prepareFiles(metaStore);
AccessCountTable table1 = new AccessCountTable("table1", 0L, 0L, false);
AccessCountTable table2 = new AccessCountTable("table2", 0L, 0L, false);
AccessCountTable table3 = new AccessCountTable("table3", 0L, 0L, false);
List<FileAccessInfo> accessInfos = metaStore.getHotFiles(Arrays.asList(table1, table2, table3), 1);
Assert.assertTrue(accessInfos.size() == 1);
FileAccessInfo expected1 = new FileAccessInfo(103L, "/file3", 7);
Assert.assertTrue(accessInfos.get(0).equals(expected1));
List<FileAccessInfo> accessInfos2 = metaStore.getHotFiles(Arrays.asList(table1, table2, table3), 2);
List<FileAccessInfo> expected2 = Arrays.asList(expected1, new FileAccessInfo(102L, "/file2", 6));
Assert.assertTrue(accessInfos2.size() == expected2.size());
Assert.assertTrue(accessInfos2.containsAll(expected2));
}
Aggregations