<null/> not supported in DBUnit standard XML format

please report bugs here

<null/> not supported in DBUnit standard XML format

Postby bruelle » Mon Jan 31, 2011 3:34 pm

The usage of the <null/> element for a cell value in standard (not flat) DBUnit XML format leads to a mismatch in column name and value arrays (<null/> is just ignored).
Example:
Code: Select all
<dataset>
    <table name="table1">
        <column>A</column>
        <column>B</column>
        <row>
            <null/>
            <value>abc</value>
        </row>
        <row>
            <value>2</value>
            <value>def</value>
        </row>
    </table>
</dataset>

If column 'A' is a numeric type for example, we would get a NumberFormatException. (<null/> is ignored, so 'abc' is taken as the value for column 'A'.

Simple patch to solve this issue:
Index: src/main/java/org/databene/platform/dbunit/DbUnitEntityIterator.java
===================================================================
--- src/main/java/org/databene/platform/dbunit/DbUnitEntityIterator.java (revision 5117)
+++ src/main/java/org/databene/platform/dbunit/DbUnitEntityIterator.java (working copy)
@@ -157,7 +157,7 @@
NodeList rows = tableNode.getElementsByTagName("row");
for (int rownum = 0; rownum < rows.getLength(); rownum++) {
Element row = (Element) rows.item(rownum);
- NodeList cellNodes = row.getElementsByTagName("value");
+ NodeList cellNodes = row.getElementsByTagName("*");
String[] values = new String[cellNodes.getLength()];
for (int cellnum = 0; cellnum < cellNodes.getLength(); cellnum++) {
Element cell = (Element) cellNodes.item(cellnum);

BTW: why not using the DBUnit Dataset abstraction (for mass data maybe a streaming implementation)?
bruelle
 
Posts: 4
Joined: Fri Jan 21, 2011 1:49 pm

Re: <null/> not supported in DBUnit standard XML format

Postby Volker Bergmann » Fri Feb 04, 2011 5:16 pm

Hi bruelle,

thank you for the patch and sorry for the late response. When you posted it I was completely focused on the latest Benerator release.

I appreciate your patch and have updated Benerator accordingly. It will be released with Benerator 0.6.5 this weekend.

I agree that a streaming implementation would have been better. Actually I cannot even imagine, why I implemented this based on DOM. Possibly because I was not yet aware of the streaming API for XML parsing.

What did you mean with 'DBUnit Dataset abstraction'?

Regards,
Volker 'databene' Bergmann

Need faster response times? phone support? onsite support? training? custom extensions? immediate bug fixes? Support Benerator evolution by buying services from Volker Bergmann!
User avatar
Volker Bergmann
 
Posts: 654
Joined: Sat Nov 10, 2007 2:40 pm

Re: <null/> not supported in DBUnit standard XML format

Postby bruelle » Mon Feb 07, 2011 2:45 pm

Sorry for being unprecise, I was just thinking of using the DUnit concept (and Java Interfcace) of a dataset as a base for the DBUnit entity source.

Another point: as far as I understood, something like the RefreshOperation of DBUnit (overwriting existing data in DB) doesn't fit into the current concept of benerator, am I right with this?
bruelle
 
Posts: 4
Joined: Fri Jan 21, 2011 1:49 pm

Re: <null/> not supported in DBUnit standard XML format

Postby Volker Bergmann » Thu Feb 10, 2011 7:02 am

Hi Bruelle,

I took a while until I was able to lean back and check the asked DbUnit features:

I was just thinking of using the DUnit concept (and Java Interfcace) of a dataset as a base for the DBUnit entity source.

You mean using DbUnits IDataSet interface and its implementations? I am trying to keep the number of external dependencies small (except for the JDBC drivers). This has the major advantage of being able to fix related bugs myself quuickly and to avoid being flooded with questions about inconsintencies that arise if a project links to different versions of an underlying library.

Another point: as far as I understood, something like the RefreshOperation of DBUnit (overwriting existing data in DB) doesn't fit into the current concept of benerator, am I right with this?

No, that's not a conceptual problem. It is just not (yet) implemented, though it would not be so difficult to do this. I am planning to provide this kind of functionality with Benerator 0.6.6, where I will need it myself for bringing the new transcoding feature to the next level.

Regards,
Volker 'databene' Bergmann

Need faster response times? phone support? onsite support? training? custom extensions? immediate bug fixes? Support Benerator evolution by buying services from Volker Bergmann!
User avatar
Volker Bergmann
 
Posts: 654
Joined: Sat Nov 10, 2007 2:40 pm

Re: <null/> not supported in DBUnit standard XML format

Postby Deminie » Mon Oct 10, 2011 8:49 am

hello)) Is it possible to specify NULL values with flat XML dataset?
Last edited by Deminie on Wed Jun 13, 2012 2:09 pm, edited 2 times in total.
Deminie
 
Posts: 1
Joined: Mon Oct 10, 2011 8:47 am

Re: <null/> not supported in DBUnit standard XML format

Postby Volker Bergmann » Tue Oct 18, 2011 4:44 pm

yes, by leaving out the corresponding attribute.

Regards,
Volker 'databene' Bergmann

Need faster response times? phone support? onsite support? training? custom extensions? immediate bug fixes? Support Benerator evolution by buying services from Volker Bergmann!
User avatar
Volker Bergmann
 
Posts: 654
Joined: Sat Nov 10, 2007 2:40 pm


Return to Benerator Bugs

Who is online

Users browsing this forum: No registered users and 2 guests

cron