Note that there are some explanatory texts on larger screens.

plurals
  1. POdbUnit data types
    text
    copied!<p>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?</p> <p>My code:</p> <pre><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); </code></pre> <p>... (further down)</p> <pre><code>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 &lt; cols.length; i++) { String colName = cols[i].getColumnName(); assertEquals(expected.getValue(rowExpected, colName), actual.getValue(rowActual, colName)); } } </code></pre> <p>This the test.xml that I slurp in: </p> <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt; &lt;!DOCTYPE dataset SYSTEM "../Tests/testdata/common/some.dtd"&gt; &lt;dataset&gt; &lt;USER ID="132" FIRST_NAME="Joe" LAST_NAME="Bob" VERIFICATION_CODE="1869" /&gt; &lt;/dataset&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload