I have been trying to use DbUnit to compare two Excel files. And I have found an "interesting" problem. I use a code similar to the following :
XlsDataSet expectedDataSet = new XlsDataSet(firstFile);
XlsDataSet actualDataSet = new XlsDataSet(secondFile);
Assertion.assertEquals(expectedDataSet, actualDataSet);
But I get an NPE. When tracing through the code, I ended up at the following code in the getValue(int row, String column) method (Line 142 in the class in dbunit-2.5.3):
Cell cell = _sheet.getRow(row + 1).getCell(columnIndex);
One of the rows in the spreadsheet is empty, and when I checked the sheet above, I see that the row is missing from the map of rows. And since the for-loop in the compareData method in DbUnitAssert assumes that all rows are present in the rows map, the code snippet above will of course fail with an NPE when it "hits" the missing row.
I have been searching to see if anybody else has had this problem, and found a workaround or some way of fixing this that doesn't involve rewriting a load of code. But so far, I have been out of luck. So I wanted to try here to see if anyone here knows any solution to this. Or if this should be addressed as a bug with the DbUnit team?
Using : POI version 3.14, DbUnit v 2.5.3.
Thanks in advance!