Search in sources :

Example 1 with DatabaseDataSourceConnection

use of org.dbunit.database.DatabaseDataSourceConnection in project head by mifos.

the class AcceptanceDatabaseTestUtils method deleteDataFromTable.

public void deleteDataFromTable(String tableName, DriverManagerDataSource dataSource) throws IOException, DataSetException, SQLException, DatabaseUnitException {
    StringReader dataSetXmlStream = new StringReader("<dataset><" + tableName + "/></dataset>");
    IDataSet dataSet = new FlatXmlDataSet(dataSetXmlStream);
    IDatabaseConnection databaseConnection = new DatabaseDataSourceConnection(dataSource);
    databaseConnection.getConfig().setProperty(DatabaseConfig.FEATURE_CASE_SENSITIVE_TABLE_NAMES, Boolean.TRUE);
    DatabaseOperation.CLEAN_INSERT.execute(databaseConnection, dataSet);
}
Also used : FlatXmlDataSet(org.dbunit.dataset.xml.FlatXmlDataSet) DatabaseDataSourceConnection(org.dbunit.database.DatabaseDataSourceConnection) StringReader(java.io.StringReader) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) IDataSet(org.dbunit.dataset.IDataSet)

Example 2 with DatabaseDataSourceConnection

use of org.dbunit.database.DatabaseDataSourceConnection in project jbehave-core by jbehave.

the class DbUnitSteps method deleteAllData.

@BeforeStory
public void deleteAllData() throws SQLException, DatabaseUnitException {
    DatabaseDataSourceConnection dbConn = new DatabaseDataSourceConnection(dataSource);
    IDataSet dataSet = dbConn.createDataSet(new String[] { "ORGANIZATION", "APPLICATION_USER" });
    DatabaseOperation.DELETE_ALL.execute(dbConn, dataSet);
}
Also used : DatabaseDataSourceConnection(org.dbunit.database.DatabaseDataSourceConnection) IDataSet(org.dbunit.dataset.IDataSet) BeforeStory(org.jbehave.core.annotations.BeforeStory)

Aggregations

DatabaseDataSourceConnection (org.dbunit.database.DatabaseDataSourceConnection)2 IDataSet (org.dbunit.dataset.IDataSet)2 StringReader (java.io.StringReader)1 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)1 FlatXmlDataSet (org.dbunit.dataset.xml.FlatXmlDataSet)1 BeforeStory (org.jbehave.core.annotations.BeforeStory)1