DataSetUpgradeUtil
Background
A Dataset is a dump of the entire contents of the Mifos database, xml-formatted by DBUnit. It is used either to initialize the database state before running an acceptance test.
When the database undergoes an upgrade (either a schema change, a change in initial data, or some other transformation of existing data) the current DBUnit datasets may no longer be valid and may either cause tests to fail or abort in error or give erroneous results. The procedure outlined below updates the datasets to reflect current schema and default data.
DataSetUpgradeUtil
DataSetUpgradeUtil is a utility that upgrades DbUnit XML data set files from a previous data version to the current database version of Mifos. It can update an individual data set file or an entire directory of data set files at once.
The utility is located in application/src/main/java/org/mifos/framework/util and works like this:
- Loads the dataset into a fresh database using the previous data schema.
- Uses the Mifos application's initialization procedures to upgrade
the schema and apply any data changes needed to bring the data up to the current version. * Uses DBUnit to dump the data, replacing the original dataset.
The easiest way to run this program is from within Eclipse, by right clicking the file DataSetUpgradeUtil.java and choosing "Run as Java Program". By clicking "Run configurations..." you get to set up arguments for the program.
All the arguments are listed when "h" or "-help" is supplied as a (command line) argument to the file.
Example single file upgrade usage
Let's say we want to upgrade a single data set filed named "acceptance_small_008_dbunit.xml.zip".
By default the database "mifos_gazelle_acceptance" is used to load and upgrade the data. Its default user is root with password mysql. You can override this configuration in your local.properties file.
Assuming that defaults are ok, set program arguments to:
-f <path-to-project-root-directory>/acceptanceTests/src/test/resources/dataSets/acceptance_small_008_dbunit.xml.zip -u root -p mysql
Example whole directory upgrade usage
Follow the setup instructions as given for single file usage, but in this case, use the directory argument -a. This example will upgrade all the *_dbunit.xml.zip files in the dataSets directory.
Set program arguments to:
-a <path-to-project-root-directory>/acceptanceTests/src/test/resources/dataSets -u root -p mysql