• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

JUnit and EJBs

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am really new to java so I may be asking something obvious or stupid, but I am looking for the best way to run JUnit tests on EJBs with local rather than remote interfaces.
When they are being used for real, they only need to be accessed locally but JUnit needs to access them remotely (or am I wrong?)
I don't really want to define them as both local and remote just for testing purposes and if I change them after testing then I won't have tested what will be released?
Any advice would be useful.
Eric.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to take a look at MockEJB, which lets you test EJBs without a container (I suppose you have previously tested your EJBs by deploying them into a real EJB container?). Here's a nice little example of how you write tests using MockEJB.
 
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read this "Test infect your Enterprise JavaBeans" article.
 
Eric Hindle
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, and so prompt too.
Eric
 
author & internet detective
Posts: 42135
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't see this in the article, but it is good to move as much business logic as possible out of the EJB and into helper classes. That way the "real" logic can be unit tested easily and the EJB can be integration tested separately.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic