You mean you have a class that does something like this?
If that's the case, all you need to do is grab the MockContextFactory class from the MockEJB project and fake the JNDI tree. There's an example of this in the freely available online bonus chapter of my book.
I am actually in the middle of the book and i might need to start from the bonus chapter (i am working with JPA and Ejb3 with JBoss).
Do you have there a solution for injection.
I mean when you have in your ejb a resource injection like @Ejb and etc I dont want to insert a IOVC framework for testing only.
Joined: Jan 23, 2002
Originally posted by avihai marchiano: I mean when you have in your ejb a resource injection like @Ejb and etc I dont want to insert a IOVC framework for testing only.
Well, you don't need any frameworks/libraries if you make your @EJB/@Resource annotated fields visible (protected, package private, public) to the test code. If you don't want to do that, you can use Java's reflection API to forcibly assign a mock to the annotated field. That's a bit clunky, though, so it would probably be easier to use a library that does the nasty reflection stuff for you. If this is the way to go, I'd recommend BeanInject.