-->
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.  [ 7 posts ] 
Author Message
 Post subject: Unit-testing hibernate classes with JUnit
PostPosted: Thu Mar 04, 2004 12:02 pm 
Beginner
Beginner

Joined: Thu Mar 04, 2004 11:51 am
Posts: 34
I like to unit-test my persistent classes with JUnit. Running these tests as either a part of an ant script or within Eclipse is a very nice environment. Back in the day when I used to write all my own JDBC and SQL code it was very easy to do this. I only had to instantiate a data source, throw it into a JNDI context and I could test my classes and they worked the same way within the container.

Now with Hibernate I find this to be a problem. I have been able to instantiate a DataSource and configure and open a Hibernate Session based on that data source, but I am being defeated by all the bells and whistles of Hibernate, many of which rely on in-container support. Things like Transaction Strategy, User Transaction, I don't know what to specify in my properties when I am not using the container (JBoss in my case). So the unit test platform feels so near and yet so far.

Has anyone successfully done this? Is there a documented instance of a successful JUnit test environment with Hibernate? Hibernate SAYS that it works well in a standalone environment, but I don't see the documentation that explains how to set one up. JUnit testing is essentially a standalone environment. Is there some complete listing of the properties needed to run Hibernate standalone that someone can supply (similar to the "quickstart" for tomcat in the docs)?

Yes, I know I could try using Cactus and in-container testing, but that is another can of worms I don't want to open unless I have to.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2004 9:15 pm 
Newbie

Joined: Thu Mar 04, 2004 9:10 pm
Posts: 6
yo... Just got this working with simple-jndi. come ask on #java in efnet or freenode if you have troubles.

_________________
THIS IS MY SIGNATURE


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 04, 2004 11:52 pm 
Beginner
Beginner

Joined: Thu Mar 04, 2004 11:51 am
Posts: 34
Hmm. Not a big IRC guy here. I tried, couldn't find the channels
(there was #java.no but no #java). And in any case I don't know your nickname. But, whatever, sounds great and we can talk in the am.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 4:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Just have different hibernate.cfg.xml for your tests
hibernate.transaction.factory_class=net.sf.hibernate.transaction.JDBCTransactionFactory

Or even better, use a standalone JTA manager such as JOTM.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 12:17 pm 
Newbie

Joined: Thu Mar 04, 2004 9:10 pm
Posts: 6
steve, you have to find a server for the efnet or freenode networks on google or something. irc.efnet.nl/irc.freenode.org work for me.

emmanuel, how does that compare to Tyrex?

_________________
THIS IS MY SIGNATURE


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 10:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Tyrex seems to have lots of features. JOTM is dedicated to TM and is the TM of JORAM (J2EE server)
I would say they do the same job (on the paper), but that piece of code can be very tricky: prefer using an active and well supported implementation. Tyrex seems not to be very active.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 4:34 pm 
Newbie

Joined: Wed Jan 28, 2004 12:41 pm
Posts: 1
ipojman wrote:
yo... Just got this working with simple-jndi. come ask on #java in efnet or freenode if you have troubles.


Ipojman if you would.. can you please keep the solution of this on the forums?
That way future people with the same problem can reference a solution without having to find you?
Thanks :)


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

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.