Search in sources :

Example 1 with FilteredDataSet

use of org.dbunit.dataset.FilteredDataSet 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);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Connection(java.sql.Connection) DatabaseConnection(org.dbunit.database.DatabaseConnection) DatabaseConnection(org.dbunit.database.DatabaseConnection) IDataSet(org.dbunit.dataset.IDataSet) FlatXmlDataSetBuilder(org.dbunit.dataset.xml.FlatXmlDataSetBuilder) File(java.io.File) FilteredDataSet(org.dbunit.dataset.FilteredDataSet)

Example 2 with FilteredDataSet

use of org.dbunit.dataset.FilteredDataSet 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"));
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) Connection(java.sql.Connection) DatabaseConnection(org.dbunit.database.DatabaseConnection) DatabaseConnection(org.dbunit.database.DatabaseConnection) FlatXmlDataSetBuilder(org.dbunit.dataset.xml.FlatXmlDataSetBuilder) File(java.io.File) FilteredDataSet(org.dbunit.dataset.FilteredDataSet)

Example 3 with FilteredDataSet

use of org.dbunit.dataset.FilteredDataSet in project cia by Hack23.

the class DataSetConnectionFactory method getDataSet.

/**
 * Gets the data set.
 *
 * @param connection
 *            the connection
 * @return the data set
 * @throws DatasetFactoryException
 *             the dataset factory exception
 */
public IDataSet getDataSet(final Connection connection) throws DatasetFactoryException {
    DatabaseConnection databaseConnection;
    try {
        databaseConnection = new DatabaseConnection(connection);
        final ITableFilter filter = new DatabaseSequenceFilter(databaseConnection);
        return new FilteredDataSet(filter, databaseConnection.createDataSet());
    } catch (DatabaseUnitException | SQLException e) {
        throw new DatasetFactoryException(e);
    }
}
Also used : SQLException(java.sql.SQLException) ITableFilter(org.dbunit.dataset.filter.ITableFilter) DatabaseUnitException(org.dbunit.DatabaseUnitException) DatabaseConnection(org.dbunit.database.DatabaseConnection) DatabaseSequenceFilter(org.dbunit.database.DatabaseSequenceFilter) FilteredDataSet(org.dbunit.dataset.FilteredDataSet)

Aggregations

DatabaseConnection (org.dbunit.database.DatabaseConnection)3 FilteredDataSet (org.dbunit.dataset.FilteredDataSet)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 Connection (java.sql.Connection)2 FlatXmlDataSetBuilder (org.dbunit.dataset.xml.FlatXmlDataSetBuilder)2 SQLException (java.sql.SQLException)1 DatabaseUnitException (org.dbunit.DatabaseUnitException)1 DatabaseSequenceFilter (org.dbunit.database.DatabaseSequenceFilter)1 IDataSet (org.dbunit.dataset.IDataSet)1 ITableFilter (org.dbunit.dataset.filter.ITableFilter)1