-->
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.  [ 2 posts ] 
Author Message
 Post subject: junit et hibernate
PostPosted: Tue Jul 12, 2005 9:02 am 
Regular
Regular

Joined: Mon Apr 25, 2005 5:36 am
Posts: 103
salut je comprends rien à cette page :


http://www.hibernate.org/123.html



Je cherche à réaliser des test unitaire sur mon appli, si qqn peut m'aider se serait sympa....

merci


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 4:39 am 
Newbie

Joined: Tue Jun 14, 2005 12:39 pm
Posts: 5
Je ne sais pas si cela peut t'aider. J'utilise junit avec hibernate et spring.

J'ai une classe :

public abstract class BaseDAOTestCase extends TestCase {
protected final Log log = LogFactory.getLog(getClass());
protected final static ApplicationContext ctx;
protected ResourceBundle rb;

static {
// String pkg = ClassUtils.classPackageAsResourcePath(Constants.class);
String[] paths = {"fr/entreprise/internet/dao/hibernate/applicationContext-resources.xml"};
ctx = new ClassPathXmlApplicationContext(paths);

}


ctx --->me permet de monter le fichier de configuration

Ensuite j'ai une classe de test qui utilise cette configuration :

public class TestCandidat extends BaseDAOTestCase {

private CandidatDAO dao = null;
private CiviliteDAO daoCivilite = null;
private Candidat candidat = null;



protected SessionFactory sessionFactory = null;

protected void setUp() throws Exception {
super.setUp();
dao = (CandidatDAO) ctx.getBean("candidatDAO");
}


protected void tearDown() throws Exception {
TransactionSynchronizationManager.unbindResource(sessionFactory);
super.tearDown();
dao=null;
}


public void testShowAllCandidat(){
List candidats=dao.getAllCandidat();
assertNotNull(candidats);
}


Si tu ne maitise pas spring et les dao je te conseille d'aller voir appfuse et de faire l'intégralite de l'exemple, cela te feras gagner énormement de temps et tu n'auras pas à reinventer la roue.

Cordialement


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