-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Transactional problems in accessing data using spring mock
PostPosted: Fri Jan 12, 2007 8:13 am 
Newbie

Joined: Fri Jan 12, 2007 8:04 am
Posts: 4
Hi,

I have setup a environment to write junits for my application(technology used :spring + hibernate + mysql + linux) using DBUnit and springmock.

I am finding trouble in accessing the data that was loaded by the DBUnit from a bean that was created by BeanFactory(SingletonBeanFactory).

Following is my setup:

I have a SampleTestCase class that extends AbstractTransactionalDataSourceSpringContextTests.

This class loads all the spring config files and data files which is used by DBUnit for data insertion. I am using HSQL in memory database, therefore all the tables are created on the fly using hibernate HBM2DDL option.

When i run this class with a method to test a create API, the following steps occur
- First all the tables are created using HBM
- Spring mock starts a new transaction
- Then DBUnit inserts all the data into tables
- Then the test method is executed
- Control goes to the ID generator class mentioned in the HBM file, id generator class creates another class CustomSequenceGenerator class using Beanfactory approach. This CustomSequenceGenerator queries the database for a sequence value that was loaded with DBUnit and scrambles it to return a primary key.

The problem is that the data loaded by dbunit is not visible for CustomSequenceGenerator class. But the same data can be accessed from the test class if i create CustomSequenceGenaratot object using applicationContext.

This particular use case uses both applicationContext and beanFactory approach of bean creation, which may be the reason for not being able to see the data loaded.

Can somebody help me in identifying the casuse and ways to overcome it.

Thanks,
Nag


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.