aspose file tools*
The moose likes Testing and the fly likes Junit and Ejb - com/ibm/ejs/jts/jts/Current Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Junit and Ejb - com/ibm/ejs/jts/jts/Current" Watch "Junit and Ejb - com/ibm/ejs/jts/jts/Current" New topic
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
    
    5
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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Junit and Ejb - com/ibm/ejs/jts/jts/Current