I'm using dBUnit and am trying to assert a row of my pre-defined FlatXmlDataSet with the actual DB dataset. The problem is the getValue for my Verification Code field returns a string when that data originates from the FlatXmlDataSet and as an Integer when its from the actual live database. This is true with any data type that isn't a String. I could write something to convert everything to a string before compare but is there a better way?
My code:
IDataSet initialSet = setupDBWithData("test.xml", true);
ITable initialTable = initialSet.getTable("USER");
String response = doTestSendVerificationPin();
assertOKResponse(response);
ITable userTable = _databaseTester.getConnection().createTable("USER");
// Make sure old user row is left unchanged
assertRowsEqual(initialTable, 0, userTable, 0);
... (further down)
protected void assertRowsEqual(ITable expected, int rowExpected, ITable actual, int rowActual) throws Exception
{
ITableMetaData metaData = expected.getTableMetaData();
Column [] cols = metaData.getColumns();
for (int i = 0; i < cols.length; i++)
{
String colName = cols[i].getColumnName();
assertEquals(expected.getValue(rowExpected, colName), actual.getValue(rowActual, colName));
}
}
This the test.xml that I slurp in:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE dataset SYSTEM "../Tests/testdata/common/some.dtd">
<dataset>
<USER ID="132" FIRST_NAME="Joe" LAST_NAME="Bob" VERIFICATION_CODE="1869" />
</dataset>