FlatXmlDataSet and tables count

View: New views
2 Messages — Rating Filter:   Alert me  

FlatXmlDataSet and tables count

by Stefano Nichele-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,
I'm using FlatXmlDataSet  to compare the content of my db with my
expected results after some operation.

This is the code I used to load my expected results:

       IDataSet expectedDataSet = new FlatXmlDataSet(new
File("test/resources/usermanager/expected-dataset-add.xml"));

but I have some issue comparing this dataset with my db content.
Basically the main problem (I think) is that if this is the content of
my xml file:

   <?xml version='1.0' encoding='UTF-8'?>
   <!DOCTYPE dataset SYSTEM "my-dataset.dtd">
   <dataset>

     <user_ userId="user1" companyId="company1" createDate="2007-03-13
   13:49:35.0" modifiedDate="2007-03-13 13:49:35.0" active_="1"/>
     <user_ userId="user2" companyId="company2" createDate="2008-04-06
   15:49:06.0" modifiedDate="2008-04-06 15:49:06.0" active_="1"/>
     <user_ userId="user3" companyId="company3" createDate="2008-04-06
   16:06:54.0" modifiedDate="2008-04-06 17:57:49.0" active_="1"/>

   </dataset>


and this is the dtd:

   <!ELEMENT dataset (
       User_*)>

   <!ELEMENT User_ EMPTY>
   <!ATTLIST User_
       userId CDATA #REQUIRED
       companyId CDATA #REQUIRED
       createDate CDATA #IMPLIED
       modifiedDate CDATA #IMPLIED
       active_ CDATA #IMPLIED
    >


Querying the dataset I have:

expectedDataSet.getTableNames().length = 3
expectedDataSet: [User_, User_, User_]

and this:

        ITable expectedTable = expectedDataSet.getTable("user_");

throws:

   org.dbunit.database.AmbiguousTableNameException: user_
           at
   org.dbunit.dataset.AbstractDataSet.getTable(AbstractDataSet.java:84)


I'm using db-unit 2.2 (but also with the latest I have the same issue),
what am I missing ? Why the number of the tables is 3 like the number of
the rows in my xml file ? Of course trying to compare this dataset with:

       // Fetch database data after executing the insert
       IDataSet databaseDataSet =
databaseTester.getConnection().createDataSet();      
throws an error since the table count is different.

Any hint is very welcome.

Cheers,
ste


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
dbunit-user mailing list
dbunit-user@...
https://lists.sourceforge.net/lists/listinfo/dbunit-user

Re: FlatXmlDataSet and tables count

by Stefano Nichele-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Issue resolved,
the table must be uppercase. Using:

   <?xml version='1.0' encoding='UTF-8'?>
   <!DOCTYPE dataset SYSTEM "my-dataset.dtd">
   <dataset>

     <USER_ userId="user1" companyId="company1" createDate="2007-03-13
   13:49:35.0" modifiedDate="2007-03-13 13:49:35.0" active_="1"/>
     <USER_ userId="user2" companyId="company2" createDate="2008-04-06
   15:49:06.0" modifiedDate="2008-04-06 15:49:06.0" active_="1"/>
     <USER_ userId="user3" companyId="company3" createDate="2008-04-06
   16:06:54.0" modifiedDate="2008-04-06 17:57:49.0" active_="1"/>

   </dataset>

but i think this should be considered a major bug.

Cheers,
ste

Stefano Nichele wrote:

> Hi All,
> I'm using FlatXmlDataSet  to compare the content of my db with my
> expected results after some operation.
>
> This is the code I used to load my expected results:
>
>        IDataSet expectedDataSet = new FlatXmlDataSet(new
> File("test/resources/usermanager/expected-dataset-add.xml"));
>
> but I have some issue comparing this dataset with my db content.
> Basically the main problem (I think) is that if this is the content of
> my xml file:
>
>    <?xml version='1.0' encoding='UTF-8'?>
>    <!DOCTYPE dataset SYSTEM "my-dataset.dtd">
>    <dataset>
>
>      <user_ userId="user1" companyId="company1" createDate="2007-03-13
>    13:49:35.0" modifiedDate="2007-03-13 13:49:35.0" active_="1"/>
>      <user_ userId="user2" companyId="company2" createDate="2008-04-06
>    15:49:06.0" modifiedDate="2008-04-06 15:49:06.0" active_="1"/>
>      <user_ userId="user3" companyId="company3" createDate="2008-04-06
>    16:06:54.0" modifiedDate="2008-04-06 17:57:49.0" active_="1"/>
>
>    </dataset>
>
>
> and this is the dtd:
>
>    <!ELEMENT dataset (
>        User_*)>
>
>    <!ELEMENT User_ EMPTY>
>    <!ATTLIST User_
>        userId CDATA #REQUIRED
>        companyId CDATA #REQUIRED
>        createDate CDATA #IMPLIED
>        modifiedDate CDATA #IMPLIED
>        active_ CDATA #IMPLIED
>     >
>
>
> Querying the dataset I have:
>
> expectedDataSet.getTableNames().length = 3
> expectedDataSet: [User_, User_, User_]
>
> and this:
>
>         ITable expectedTable = expectedDataSet.getTable("user_");
>
> throws:
>
>    org.dbunit.database.AmbiguousTableNameException: user_
>            at
>    org.dbunit.dataset.AbstractDataSet.getTable(AbstractDataSet.java:84)
>
>
> I'm using db-unit 2.2 (but also with the latest I have the same issue),
> what am I missing ? Why the number of the tables is 3 like the number of
> the rows in my xml file ? Of course trying to compare this dataset with:
>
>        // Fetch database data after executing the insert
>        IDataSet databaseDataSet =
> databaseTester.getConnection().createDataSet();      
> throws an error since the table count is different.
>
> Any hint is very welcome.
>
> Cheers,
> ste
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> dbunit-user mailing list
> dbunit-user@...
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>
>  


--
Stefano Nichele

Funambol Servers Tech Lead
funambol :: mobile open source :: http://www.funambol.com


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
dbunit-user mailing list
dbunit-user@...
https://lists.sourceforge.net/lists/listinfo/dbunit-user