use of org.dbunit.dataset.xml.FlatXmlDataSetBuilder in project head by mifos.
the class MifosIntegrationTestCase method dbVerificationTearDown.
private void dbVerificationTearDown() throws Exception, FileNotFoundException, MalformedURLException {
if (verifyDatabaseState) {
Connection connection = StaticHibernateUtil.getSessionTL().connection();
connection.setAutoCommit(false);
DatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
IDataSet upgradeDataDump = new FilteredDataSet(excludeTables, dbUnitConnection.createDataSet());
String tmpDir = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator");
FlatXmlDataSet.write(upgradeDataDump, new FileOutputStream(tmpDir + "upgradeDataDump.xml"));
FlatXmlDataSetBuilder fxmlBuilder = new FlatXmlDataSetBuilder();
upgradeDataDump = fxmlBuilder.build(new File(tmpDir + "upgradeDataDump.xml"));
Assertion.assertEquals(latestDataDump, upgradeDataDump);
}
}
use of org.dbunit.dataset.xml.FlatXmlDataSetBuilder in project head by mifos.
the class MifosIntegrationTestCase method dbVerificationSetUp.
private void dbVerificationSetUp() throws Exception {
if (verifyDatabaseState) {
excludeTables.excludeTable("BATCH_JOB_EXECUTION");
Connection connection = StaticHibernateUtil.getSessionTL().connection();
connection.setAutoCommit(false);
DatabaseConnection dbUnitConnection = new DatabaseConnection(connection);
latestDataDump = new FilteredDataSet(excludeTables, dbUnitConnection.createDataSet());
String tmpDir = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator");
FlatXmlDataSet.write(latestDataDump, new FileOutputStream(tmpDir + "latestDataDump.xml"));
FlatXmlDataSetBuilder fxmlBuilder = new FlatXmlDataSetBuilder();
latestDataDump = fxmlBuilder.build(new File(tmpDir + "latestDataDump.xml"));
}
}
use of org.dbunit.dataset.xml.FlatXmlDataSetBuilder in project head by mifos.
the class DbUnitUtilities method getDataSetFromClasspathFile.
public IDataSet getDataSetFromClasspathFile(String filename, String directory) throws IOException, DataSetException {
ClassPathResource resource = new ClassPathResource(directory + filename);
File file = resource.getFile();
if (file == null) {
throw new FileNotFoundException("Couldn't find file:" + filename);
}
FlatXmlDataSetBuilder fb = new FlatXmlDataSetBuilder();
fb.setColumnSensing(true);
fb.setDtdMetadata(false);
return fb.build(file);
}
use of org.dbunit.dataset.xml.FlatXmlDataSetBuilder in project sharding-jdbc by dangdangdotcom.
the class AbstractDBUnitTest method importDataSet.
@Before
public final void importDataSet() throws Exception {
for (String each : getDataSetFiles()) {
InputStream is = AbstractDBUnitTest.class.getClassLoader().getResourceAsStream(each);
IDataSet dataSet = new FlatXmlDataSetBuilder().build(new InputStreamReader(is));
IDatabaseTester databaseTester = new ShardingJdbcDatabaseTester(dbEnv.getDriverClassName(), dbEnv.getURL(getFileName(each)), dbEnv.getUsername(), dbEnv.getPassword());
databaseTester.setSetUpOperation(DatabaseOperation.CLEAN_INSERT);
databaseTester.setDataSet(dataSet);
databaseTester.onSetup();
}
}
use of org.dbunit.dataset.xml.FlatXmlDataSetBuilder in project microservices by pwillhan.
the class SampleDataImporter method onStartup.
public void onStartup(@Observes @Initialized(ApplicationScoped.class) Object event) throws Exception {
InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("testdata.xml");
IDatabaseConnection connection = new JndiDatabaseTester("java:jboss/datasources/ExampleDS").getConnection();
DatabaseOperation.CLEAN_INSERT.execute(connection, new FlatXmlDataSetBuilder().build(input));
if (connection != null) {
try {
connection.close();
} catch (Exception ex) {
ex.printStackTrace(System.err);
}
} else {
System.err.println("Can't import test data, check connection settings!");
}
}
Aggregations