| Author |
Junit and Ejb - com/ibm/ejs/jts/jts/Current
|
Alana Sparx
Ranch Hand
Joined: Feb 14, 2006
Posts: 121
|
|
Hi all I've been trying to write a Junit test class for an ejb that delegates calls to various business services. I've tried bypassing the Ejb and calling the services directly, but either way the same error appears (as the Business Services ultimately call the database, therefor the contect needs to be set up). The error could just be a classpath conflict (com/ibm/ejs/jts/jts/Current), but I cannot find the appropriate class or jar anywhere. I'm Using Websphere 5.1. The error is How else can I test this - how would I 'mock' a call to the database without altering the business code? Thanx As
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
The stack trace you posted implies that the code you're invoking eventually does a JNDI lookup to find a DataSource. You can use MockEJB for setting up a fake, local JNDI tree and bind whatever objects you want to it, therefore making your JNDI lookup for "jdbc/ds1" obtain exactly what you want instead of the real thing. In your case, you might bind a mock object that you've configured with tools like EasyMock or jMock, or alternatively an actual DataSource object that connects to a local, embedded database such as HSQLDB.
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
 |
|
|
subject: Junit and Ejb - com/ibm/ejs/jts/jts/Current
|
|
|