wood burning stoves 2.0*
The moose likes Testing and the fly likes What framework should I use to mock an EJB using Spring 3, EJB 2.0? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "What framework should I use to mock an EJB using Spring 3, EJB 2.0?" Watch "What framework should I use to mock an EJB using Spring 3, EJB 2.0?" New topic
Author

What framework should I use to mock an EJB using Spring 3, EJB 2.0?

Dave Alvarado
Ranch Hand

Joined: Jul 02, 2008
Posts: 436

Hi,

I'm using Spring 3.1.0.RELEASE and JUnit 4.8.1. I want to mock a deployment of a stateless session EJB but not sure what framework I should be using given the following. I want to test my Spring controller, which looks up an EJB using this code …



I set up the Spring test like so …



The EJB I'm deploying is in a JAR file that contains a META-INF/ejb-jar.xml file that declares my EJBs (as opposed to annotations) like so …



Given this, what framework should I use for mocking the EJB container and binding my EJB to the proper JNDI name? I looked at Arquillian, but it seems it requires you to declare "@RunWith" at the top of your test, and JUnit only allows one "@RunWith" declaration.

- Dave
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Any mock framework should be ok. jMock, easyMock and PowerMock are very common.

I'm not familiar with Arquillian, but sometimes the @RunWith isn't mandatory. In JMock, @RunWith is available as a convenience. But the test still works without it and you can call verify() manually.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: What framework should I use to mock an EJB using Spring 3, EJB 2.0?
 
Similar Threads
Name comp/env/ejb not found in context "java:" application client problem
How to get the datasource from Bean through deployment descriptor
JNDI/Deployment Error WLS 7
xdoclet problem while generating ejb-jar.xml
Urgent help needed - Thanks