tryToExecute(datasets);
}
private void tryToExecute(List<DataSupplier> datasets) {
IDatabaseConnection conn = connections.get(); // don't get conned
try {
disableReferentialIntegrity(conn);
for (DataSupplier op : datasets) {
try {
IDataSet dataSet = op.get();
DatabaseOperation operacao = op.getOperation();
DatabaseOperation trx = DatabaseOperation.TRANSACTION(operacao);
trx.execute(conn, dataSet);
} catch (Exception e) {
Throwables.propagateIfInstanceOf(e, DBUnitSetupException.class);
String msg = String.format("Could not load DBUnit file: %s", op.getFilename());
throw new DBUnitSetupException(msg, e);
}
}
enableReferentialIntegrity(conn);
} finally {
try {
conn.close();
} catch (SQLException e) {
// move along, nothing to see here
}
}