• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Dave Alvarado
Ranch Hand
Posts: 436
  • 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
Sheriff
Posts: 36446
454
Eclipse IDE Java VI Editor
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!