-->
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.  [ 6 posts ] 
Author Message
 Post subject: JUnit - ing you hibernate application
PostPosted: Sun Feb 08, 2004 3:45 am 
Beginner
Beginner

Joined: Sun Dec 21, 2003 9:18 pm
Posts: 21
Hi All,

As one of eXtreme programming fans, i always try to test my applications. And this comes no difference with hibernate.

Just a while ago i found out that when I run my junit test, hibernate will tries to read from the datasource that I use for my Resin web server.

But unfortunately a data source cannot be run outside a webserver, and thus threw me : "unable to find data source" error.

So my approach in testing is that I will use a DAO that will return me connection from 2 different source. WHen i run my application using REsin my DAO will return me a connection from the datasource and if i am not using Resin e.g. JUnit, it will give me connection through the old good fashioned :

Code:
DriverManager.getConnection("jdbc:postgresql://localhost/blah",
"username", "password");


But I am wondering whether there is an easier way to test Hibernate witohut using these approach.

Regards,
-e-null-


Top
 Profile  
 
 Post subject: Re: JUnit - ing you hibernate application
PostPosted: Sun Feb 08, 2004 6:04 am 
Newbie

Joined: Tue Jan 27, 2004 3:26 pm
Posts: 18
inoel131081 wrote:
So my approach in testing is that I will use a DAO that will return me connection from 2 different source. WHen i run my application using REsin my DAO will return me a connection from the datasource and if i am not using Resin e.g. JUnit, it will give me connection through the old good fashioned :

Code:
DriverManager.getConnection("jdbc:postgresql://localhost/blah",
"username", "password");


But I am wondering whether there is an easier way to test Hibernate witohut using these approach.


Why don't you use in-container tests based on, for instance, jakarta's Cactus?

Artur


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2004 8:35 am 
Beginner
Beginner

Joined: Sun Dec 21, 2003 9:18 pm
Posts: 21
the problem is that i fail to setup cactus :( and i am more comfortable with JUnit to test my business objects.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 08, 2004 8:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Abstract out the method you use to collect the session factory. This will allow the same code (DAOs) to operate independently of the environment.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 09, 2004 3:56 am 
Newbie

Joined: Tue Jan 27, 2004 3:26 pm
Posts: 18
inoel131081 wrote:
the problem is that i fail to setup cactus :( and i am more comfortable with JUnit to test my business objects.


Take a look at this http://www.javaranch.com/codebarn.jsp. Hope it helps.

Artur


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2004 9:54 pm 
Beginner
Beginner

Joined: Sun Dec 21, 2003 9:18 pm
Posts: 21
karaznie wrote:
inoel131081 wrote:
the problem is that i fail to setup cactus :( and i am more comfortable with JUnit to test my business objects.


Take a look at this http://www.javaranch.com/codebarn.jsp. Hope it helps.

Artur


It seems like this is a broken links. But thanks anyway. ^_^


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.