What is the best way to integration test EJBs and REST-Resources?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do that through the EJB 3.1 EJBContainer API with a container that supports more than EJB lite. EJB lite is meant to be a minimum rather than a maximum.
I know OpenEJB supports JAX-RS embedded, not sure on others. If they support JAX-RS through an embedded Arquillian adapter, they should be able to support it via the standard EJBContainer API which is meant for Java SE usage like testing or standalone apps.
Here’s an example:
That one is not well documented, so here are the highlights.
First, include the Embedded container libraries. In this case that is the following maven dependency:
Then in your testcase, boot the EJBContainer:
You’re good to go, now you can send requests to your service. Using the CXF WebClient, that might look like this:
Of course plain URL or Commons HttpClient works as well.