use of org.dbunit.dataset.IDataSet in project head by mifos.
the class SavingsDepositTest method makeDepositToClientSavingsAccount.
// one of the dependent methods throws Exception
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public void makeDepositToClientSavingsAccount() throws Exception {
initData();
DepositWithdrawalSavingsParameters params = new DepositWithdrawalSavingsParameters();
params.setTrxnDateMM("09");
params.setTrxnDateDD("09");
params.setTrxnDateYYYY("2009");
params.setAmount("543.2");
params.setPaymentType(DepositWithdrawalSavingsParameters.CASH);
params.setTrxnType(DepositWithdrawalSavingsParameters.DEPOSIT);
params.setReceiptDateDD("09");
params.setReceiptDateMM("09");
params.setReceiptDateYYYY("2009");
SavingsAccountDetailPage accountDetailPage = savingsAccountHelper.makeDepositOrWithdrawalOnSavingsAccount("000100000000036", params);
String[] tablesToRetrieve = { "SAVINGS_ACTIVITY_DETAILS", "SAVINGS_ACCOUNT", "SAVINGS_PERFORMANCE", "SAVINGS_TRXN_DETAIL" };
String[] tablesToValidate = { "SAVINGS_ACTIVITY_DETAILS", "SAVINGS_ACCOUNT", "SAVINGS_PERFORMANCE" };
IDataSet expectedDataSet = dbUnitUtilities.getDataSetFromDataSetDirectoryFile("SavingsDeposit_001_result_dbunit.xml");
IDataSet databaseDataSet = dbUnitUtilities.getDataSetForTables(dataSource, tablesToRetrieve);
dbUnitUtilities.verifyTables(tablesToValidate, databaseDataSet, expectedDataSet);
// verify savings transaction table with sorting
String[] orderSavingsTrxnByColumns = new String[] { "deposit_amount" };
dbUnitUtilities.verifyTableWithSort(orderSavingsTrxnByColumns, SavingsDepositTest.SAVINGS_TRXN_DETAIL, expectedDataSet, databaseDataSet);
// verify transaction history table
TransactionHistoryPage historyPage = accountDetailPage.navigateToTransactionHistoryPage();
historyPage.verifyTableTypeAfterDeposit(2);
}
use of org.dbunit.dataset.IDataSet in project sharding-jdbc by dangdangdotcom.
the class AbstractDBUnitTest method assertDataSet.
protected void assertDataSet(final String expectedDataSetFile, final Connection connection, final String actualTableName, final String sql) throws SQLException, DatabaseUnitException {
try (Connection conn = connection) {
ITable actualTable = getConnection(conn).createQueryTable(actualTableName, sql);
IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(new InputStreamReader(AbstractDBUnitTest.class.getClassLoader().getResourceAsStream(expectedDataSetFile)));
assertEquals(expectedDataSet.getTable(actualTableName), actualTable);
}
}
use of org.dbunit.dataset.IDataSet in project sharding-jdbc by dangdangdotcom.
the class AbstractDBUnitTest method assertDataSet.
protected void assertDataSet(final String expectedDataSetFile, final Connection connection, final String actualTableName, final String sql, final Object... params) throws SQLException, DatabaseUnitException {
try (Connection conn = connection;
PreparedStatement ps = conn.prepareStatement(sql)) {
int i = 1;
for (Object each : params) {
ps.setObject(i++, each);
}
ITable actualTable = getConnection(connection).createTable(actualTableName, ps);
IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(new InputStreamReader(AbstractDBUnitTest.class.getClassLoader().getResourceAsStream(expectedDataSetFile)));
assertEquals(expectedDataSet.getTable(actualTableName), actualTable);
}
}
use of org.dbunit.dataset.IDataSet in project head by mifos.
the class DbUnitUtilities method getDataSetForTables.
/**
* Returns a DbUnit DataSet for several tables.
* @param driverManagerDataSource TODO
* @param tableNames
* @return IDataSet
* @throws Exception
*/
// one of the dependent methods throws Exception
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public IDataSet getDataSetForTables(DriverManagerDataSource driverManagerDataSource, String[] tableNames) throws Exception {
Connection jdbcConnection = null;
IDataSet databaseDataSet = null;
try {
jdbcConnection = DataSourceUtils.getConnection(driverManagerDataSource);
IDatabaseTester databaseTester = new DataSourceDatabaseTester(driverManagerDataSource);
IDatabaseConnection databaseConnection = databaseTester.getConnection();
databaseDataSet = databaseConnection.createDataSet(tableNames);
} finally {
jdbcConnection.close();
DataSourceUtils.releaseConnection(jdbcConnection, driverManagerDataSource);
}
return databaseDataSet;
}
use of org.dbunit.dataset.IDataSet in project head by mifos.
the class DatabaseTestUtils method cleanAndInsertDataSetWithColumnSensing.
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public //Rationale: You cannot define new local variables in the try block because the finally block must reference it.
void cleanAndInsertDataSetWithColumnSensing(String xmlString, DriverManagerDataSource dataSource) throws IOException, DataSetException, SQLException, DatabaseUnitException {
IDataSet dataSet = getXmlDataSet(xmlString);
cleanAndInsertDataSet(dataSource, dataSet);
}
Aggregations