Dbunit appears to not be loading my database

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

Dbunit appears to not be loading my database

Tom Masterson-2
I am using MySQL version 5.5, dbunit 2.4.8, junit 4, and spring 3.x.

>From the large amount of debug info put out by dbunit in trace mode it
appears that it is getting the data set correctly and it appears to be
putting it in the database at least no errors are thrown and I am not
seeing anything obvious in the log file.  All the setup for dbunit and the
running of the databseTester.onSetup is done in the setup method of my
test.

When I run a test case to check whether my code is retrieving properly
from the database it shows no records in the tables.  I know there should
be at least five records in the table I am getting data from.  If I set
things up in such a way that the tables are not rolled back or otherwise
deleted after the tests mysql also tells me the tables are empty.  At this
point I am out of ideas of where to even begin looking.  Any thoughts on
where to start?

Thanks
Tom

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Dbunit appears to not be loading my database

John Hurst-2
Do you commit the data into the database? If you don't commit you won't see any data in the tables when you look after the test.

Is it possible that the test code uses a different connection from the setup code. Again, if data are not committed then other connections should not be able to see those data.

I am not experienced with MySQL. I assume you are using an engine that supports transactions. 

John Hurst
Wellington, New Zealand


On Thu, Nov 22, 2012 at 12:51 PM, Tom Masterson <[hidden email]> wrote:
I am using MySQL version 5.5, dbunit 2.4.8, junit 4, and spring 3.x.

>From the large amount of debug info put out by dbunit in trace mode it
appears that it is getting the data set correctly and it appears to be
putting it in the database at least no errors are thrown and I am not
seeing anything obvious in the log file.  All the setup for dbunit and the
running of the databseTester.onSetup is done in the setup method of my
test.

When I run a test case to check whether my code is retrieving properly
from the database it shows no records in the tables.  I know there should
be at least five records in the table I am getting data from.  If I set
things up in such a way that the tables are not rolled back or otherwise
deleted after the tests mysql also tells me the tables are empty.  At this
point I am out of ideas of where to even begin looking.  Any thoughts on
where to start?

Thanks
Tom

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user



--
Life is interfering with my game

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Dbunit appears to not be loading my database

Tom Masterson-2
After reading through and trying to match mysql logs with logs from my
test I have found the following that appears to be happening.

I currently have spring set to not rollback the transaction at the end of
the test.  It appears from mysql that dbunit is putting the data from the
xml files in the database upon calling the onsetup on the databaseTester.
However something is causing a rollback as soon as the connection is
closed.  I am not finding anything that is doing the rollback.  If i
directly insert data into the database in a test it goes in and stays in
however with dbunit setting up the data in the @before/setup method for
the class the dbunit data gets rolled back before any tests are run.

even more confused.  I have looked at jdbc connection logging but that
involves some reworking of drivers and I would prefer not to do that if I
can avoid it.  Not sure it will tell me any more than what the spring,
hibernate, dbunit and mysql query logs are telling me.
  Tom

On Wed, 21 Nov 2012, Tom Masterson wrote:

> As far as I know dbunit does a commit when it loads a dataset into the
> database.  The engine I am using is transactional and the insertion of the
> data from dbunit and the test are in the same transaction.  I believe they
> are probably two different connections as dbunit opens a connection, inserts
> data, and then closes that connection again in it's clean_insert operation.
> More specifically it opens the connection, deletes all data in the tables,
> iserts the dataset, and then closes the connection.  What I am not seeing
> from the database side is the insertion of the data even when the transaction
> is not rolled back so at the end anything inserted shoud be there.
>
> Tom
>
> On Thu, 22 Nov 2012, John Hurst wrote:
>
>> Do you commit the data into the database? If you don't commit you won't see
>> any data in the tables when you look after the test.
>> Is it possible that the test code uses a different connection from the
>> setup code. Again, if data are not committed then other connections should
>> not be able to see
>> those data.
>>
>> I am not experienced with MySQL. I assume you are using an engine that
>> supports transactions. 
>>
>> John Hurst
>> Wellington, New Zealand
>>
>>
>> On Thu, Nov 22, 2012 at 12:51 PM, Tom Masterson <[hidden email]> wrote:
>>       I am using MySQL version 5.5, dbunit 2.4.8, junit 4, and spring 3.x.
>>
>>       >From the large amount of debug info put out by dbunit in trace mode
>> it
>>       appears that it is getting the data set correctly and it appears to
>> be
>>       putting it in the database at least no errors are thrown and I am not
>>       seeing anything obvious in the log file.  All the setup for dbunit
>> and the
>>       running of the databseTester.onSetup is done in the setup method of
>> my
>>       test.
>>
>>       When I run a test case to check whether my code is retrieving
>> properly
>>       from the database it shows no records in the tables.  I know there
>> should
>>       be at least five records in the table I am getting data from.  If I
>> set
>>       things up in such a way that the tables are not rolled back or
>> otherwise
>>       deleted after the tests mysql also tells me the tables are empty.  At
>> this
>>       point I am out of ideas of where to even begin looking.  Any thoughts
>> on
>>       where to start?
>>
>>       Thanks
>>       Tom
>>
>>       ------------------------------------------------------------------------------
>>       Monitor your physical, virtual and cloud infrastructure from a single
>>       web console. Get in-depth insight into apps, servers, databases,
>> vmware,
>>       SAP, cloud infrastructure, etc. Download 30-day Free Trial.
>>       Pricing starts from $795 for 25 servers or applications!
>>       http://p.sf.net/sfu/zoho_dev2dev_nov
>>       _______________________________________________
>>       dbunit-user mailing list
>>       [hidden email]
>>       https://lists.sourceforge.net/lists/listinfo/dbunit-user
>>
>>
>>
>>
>> --
>> Life is interfering with my game
>>
>
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user
Reply | Threaded
Open this post in threaded view
|

Re: Dbunit appears to not be loading my database

John Hurst-2
So if you close a connection without a commit, isn't a rollback expected?

Are you expecting the commit from DbUnit? 

John Hurst



On Wed, Nov 28, 2012 at 1:46 PM, Tom Masterson <[hidden email]> wrote:
After reading through and trying to match mysql logs with logs from my test I have found the following that appears to be happening.

I currently have spring set to not rollback the transaction at the end of the test.  It appears from mysql that dbunit is putting the data from the xml files in the database upon calling the onsetup on the databaseTester. However something is causing a rollback as soon as the connection is closed.  I am not finding anything that is doing the rollback.  If i directly insert data into the database in a test it goes in and stays in however with dbunit setting up the data in the @before/setup method for the class the dbunit data gets rolled back before any tests are run.

even more confused.  I have looked at jdbc connection logging but that involves some reworking of drivers and I would prefer not to do that if I can avoid it.  Not sure it will tell me any more than what the spring, hibernate, dbunit and mysql query logs are telling me.
 Tom


On Wed, 21 Nov 2012, Tom Masterson wrote:

As far as I know dbunit does a commit when it loads a dataset into the database.  The engine I am using is transactional and the insertion of the data from dbunit and the test are in the same transaction.  I believe they are probably two different connections as dbunit opens a connection, inserts data, and then closes that connection again in it's clean_insert operation. More specifically it opens the connection, deletes all data in the tables, iserts the dataset, and then closes the connection.  What I am not seeing from the database side is the insertion of the data even when the transaction is not rolled back so at the end anything inserted shoud be there.

Tom

On Thu, 22 Nov 2012, John Hurst wrote:

Do you commit the data into the database? If you don't commit you won't see any data in the tables when you look after the test.
Is it possible that the test code uses a different connection from the setup code. Again, if data are not committed then other connections should not be able to see
those data.

I am not experienced with MySQL. I assume you are using an engine that supports transactions. 

John Hurst
Wellington, New Zealand


On Thu, Nov 22, 2012 at 12:51 PM, Tom Masterson <[hidden email]> wrote:
      I am using MySQL version 5.5, dbunit 2.4.8, junit 4, and spring 3.x.

      >From the large amount of debug info put out by dbunit in trace mode it
      appears that it is getting the data set correctly and it appears to be
      putting it in the database at least no errors are thrown and I am not
      seeing anything obvious in the log file.  All the setup for dbunit and the
      running of the databseTester.onSetup is done in the setup method of my
      test.

      When I run a test case to check whether my code is retrieving properly
      from the database it shows no records in the tables.  I know there should
      be at least five records in the table I am getting data from.  If I set
      things up in such a way that the tables are not rolled back or otherwise
      deleted after the tests mysql also tells me the tables are empty.  At this
      point I am out of ideas of where to even begin looking.  Any thoughts on
      where to start?

      Thanks
      Tom

      ------------------------------------------------------------------------------
      Monitor your physical, virtual and cloud infrastructure from a single
      web console. Get in-depth insight into apps, servers, databases, vmware,
      SAP, cloud infrastructure, etc. Download 30-day Free Trial.
      Pricing starts from $795 for 25 servers or applications!
      http://p.sf.net/sfu/zoho_dev2dev_nov
      _______________________________________________
      dbunit-user mailing list
      [hidden email]
      https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game


------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user




--
Life is interfering with my game

------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
INSIGHTS What's next for parallel hardware, programming and related areas?
Interviews and blogs by thought leaders keep you ahead of the curve.
http://goparallel.sourceforge.net
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user