Testing EJB's
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mathur_neni
Posted On:   Sunday, July 31, 2005 02:10 PM

How do I test the EJB with a Junit test case? I am getting some lookup problems.

THanks in advance.

Re: Testing EJB's

Posted By:   Stephen_Smith  
Posted On:   Wednesday, August 10, 2005 08:36 AM

You're getting lookup problems because JUnit is a J2SE framework, while EJBs are J2EE and therefore require a container (e.g. an application server such as JBoss).


The solution to this problem is not actually test the deployment of your EJBs (which after all is a container issue, and something that probably isn't of great concern to you), and test the actual internal behaviour of the EJBs. When you think about it, this doesn't actually require J2EE, so you can "mock" your EJBs to test them.


I recommend http://mockejb.sourceforge.net as an excellent starting point. You only have to add a couple of lines to your TestCase#setUp to establish a mock JNDI environment and deploy your EJBs, and then you're away!

About | Sitemap | Contact