Dynamic content on DbUnit tests

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic content on DbUnit tests

Gerardo Albela González
Hi,

I have just joined the group so, first of all, hello everybody and thanks in advance for your comments and your help.

I have been for a while now working with Selenium and DbUnit to develop a framework to test the web interface my company offers to our customers.

The problem I have just hit is that there is a section where some actions the users have perfomed are only shown when they have been performed within the last 15 days. For this reason, I would like to do something like the following:

    <tblAction
        pkAction_ID="10000"
        Action="STP"
        FilterFlag="0"
        CreatedBy="p2test"
        CreatedTime="DATE_ADD(CURRENT_DATE(), INTERVAL 2 HOUR)"/>

Unfortunately, that seems not to be accepted on DbUnit, which I believe is expecting to find a 'datetime' value for the CreatedTime field.

Is there any way that you know of doing something similar to that? The only way I can think about right now is to modify the XML file from the Java Selenium test, but it would be nice to avoid that if possible.

Thanks again,

Gerardo Albela



------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic content on DbUnit tests

Dave S-B
You can use a ReplacementDataSet (see here for info -
http://www.dbunit.org/components.html - in the IDataSet section).

So, your XML would be something like this...

<tblAction
pkAction_ID="10000"
Action="STP"
FilterFlag="0"
CreatedBy="p2test"
CreatedTime="[created_time]"/>

...and you'd get the dataset like this...

ReplacementDataSet dataSet = new ReplacementDataSet(new FlatXmlDataSet(…));
dataSet.addReplacementObject("[created_time]", dateObject);

... where you've set up the date object to the required date/time beforehand.

Regards
Dave S-B
Lledr Solutions



Gerardo Albela González wrote:

> Hi,
>
> I have just joined the group so, first of all, hello everybody and
> thanks in advance for your comments and your help.
>
> I have been for a while now working with Selenium and DbUnit to
> develop a framework to test the web interface my company offers to our
> customers.
>
> The problem I have just hit is that there is a section where some
> actions the users have perfomed are only shown when they have been
> performed within the last 15 days. For this reason, I would like to do
> something like the following:
>
> <tblAction
> pkAction_ID="10000"
> Action="STP"
> FilterFlag="0"
> CreatedBy="p2test"
> CreatedTime="DATE_ADD(CURRENT_DATE(), INTERVAL 2 HOUR)"/>
>
> Unfortunately, that seems not to be accepted on DbUnit, which I
> believe is expecting to find a 'datetime' value for the CreatedTime field.
>
> Is there any way that you know of doing something similar to that? The
> only way I can think about right now is to modify the XML file from
> the Java Selenium test, but it would be nice to avoid that if possible.
>
> Thanks again,
>
> Gerardo Albela
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Are you an open source citizen? Join us for the Open Source Bridge conference!
> Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
> Need another reason to go? 24-hour hacker lounge. Register today!
> http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
> ------------------------------------------------------------------------
>
> _______________________________________________
> dbunit-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/dbunit-user
>  
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.374 / Virus Database: 270.12.88/2196 - Release Date: 06/22/09 18:11:00
>
>  


------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user