Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I test EJB 3.0?

I am using EJB 3.0 , Oracle WebLogic.

Need help in the following question :

How to test EJB (3.0) ? I mean unit tests and/or integration tests ? Can I use some kind of embedded EJB container or create a mock for it to write unit tests ? Maybe there is some special test frameworks or aproaches? EJB aren't new for me, but I have never written tests for them. Any information will be useful for me .

Thanks.

like image 397
ikos23 Avatar asked Dec 18 '13 17:12

ikos23


1 Answers

One option is using embedded container. Starts up on every test execution, you have to get your beans through jndi lookup, manage container's configuration yourself and all kind of boring, unproductive stuff.

On the other hand, there are frameworks like Arquillian, that do the thing for you. It supports annotations like @EJB in tests and does DI, manages container.... Read the guide on their website, its worth it.

From my experience, mocks are a no good solution for complex ejb testing, even though it may work on testing some non-container dependant functionality.

My advice is going on it with arquillian.

like image 138
awb Avatar answered Oct 27 '22 15:10

awb