File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Dave Alvarado
Ranch Hand
Posts: 436
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic