You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Rakesh Arora <ra...@nortel.com> on 2009/02/26 22:28:24 UTC

Is it possible to insert a mock implementation of EJB that is being referenced using @EJB annotation

I am trying to unit test an EJB (say: x) that refers and uses other EJBs
(say: y and z) using @EJB annotation. I want to insert mock implementation
of y and z durng my unit testing of x. Is it possible to do that using
openEJB?

Thanks,
-Rakesh
-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-insert-a-mock-implementation-of-EJB-that-is-being-referenced-using-%40EJB-annotation-tp22234086p22234086.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Is it possible to insert a mock implementation of EJB that is being referenced using @EJB annotation

Posted by Jean-Louis MONTEIRO <je...@atosorigin.com>.
It's a very nice feature.
I was not aware about that.

It's also possible to manage such a configuration using maven
profile/filtering.
It's not always simple to do.

Thanks David for the input.

Regards,
Jean-Louis




David Blevins wrote:
> 
> 
> On Feb 26, 2009, at 1:28 PM, Rakesh Arora wrote:
>> I am trying to unit test an EJB (say: x) that refers and uses other  
>> EJBs
>> (say: y and z) using @EJB annotation. I want to insert mock  
>> implementation
>> of y and z durng my unit testing of x. Is it possible to do that using
>> openEJB?
> 
> We do have some new functionality (say 3 weeks old) that might help you.
> 
> I've just whipped up some basic documentation for it here:
> 
>   http://cwiki.apache.org/OPENEJBx30/alternate-descriptors.html
> 
> You could essentially use a "mock" ejb-jar.xml to override the value  
> of the <ejb-class> to point at a mock implementation you create.  This  
> could be done as many times as you need.
> 
> This mocking sort of feature set is definitely one that I think could  
> be expanded.  This feature above is a good start, but I suspect you  
> will end up with a few utility classes that help with things you find  
> yourself doing frequently.  We are definitely happy to incorporate  
> them directly into the project and offer them to others, even code  
> that incorporates other frameworks like MockObjects (anything goes as  
> long as it's open source and not GPL or LGPL).
> 
> We[1] could definitely use some more trail blazers in the mocking area.
> 
> -David
> 
> [1] we = you + me + everyone
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Is-it-possible-to-insert-a-mock-implementation-of-EJB-that-is-being-referenced-using-%40EJB-annotation-tp22234086p22304650.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Re: Is it possible to insert a mock implementation of EJB that is being referenced using @EJB annotation

Posted by David Blevins <da...@visi.com>.
On Feb 26, 2009, at 1:28 PM, Rakesh Arora wrote:
> I am trying to unit test an EJB (say: x) that refers and uses other  
> EJBs
> (say: y and z) using @EJB annotation. I want to insert mock  
> implementation
> of y and z durng my unit testing of x. Is it possible to do that using
> openEJB?

We do have some new functionality (say 3 weeks old) that might help you.

I've just whipped up some basic documentation for it here:

  http://cwiki.apache.org/OPENEJBx30/alternate-descriptors.html

You could essentially use a "mock" ejb-jar.xml to override the value  
of the <ejb-class> to point at a mock implementation you create.  This  
could be done as many times as you need.

This mocking sort of feature set is definitely one that I think could  
be expanded.  This feature above is a good start, but I suspect you  
will end up with a few utility classes that help with things you find  
yourself doing frequently.  We are definitely happy to incorporate  
them directly into the project and offer them to others, even code  
that incorporates other frameworks like MockObjects (anything goes as  
long as it's open source and not GPL or LGPL).

We[1] could definitely use some more trail blazers in the mocking area.

-David

[1] we = you + me + everyone