The JavaEE sample project uses the Arquillian framework in order to create a micro deployment for in-container testing.
With Arquillian the tests are executed within application container boundaries. The sample uses the Wildfly application server
as container and provides access to EJB resources, Mail services and JNDI JMS resources such as destinations and connection factories.
The sample integrates with Citrus and Arquillian for automated integration testing of JavaEE applications. You can read more about the
cooperation of Citrus and Arquillian in reference guide.
The system under test is a JavaEE EJB application that manages employees in a company. We can add, edit and remove employees in a registry over
multiple APIs. The application provides a REST and JMS API for managing the list of employees known to the system.
In a test scenario the needed classes are deployed as Shrinkwrap micro deployments in the Wildfly application container. The Arquillian
framework gives access to container managed resources such as JNDI resources and dependency injection via CDI.
The Maven project POM includes the Arquillian dependencies in combination with an managed Wildfly container.
The dependencies include the javaee-api, shrinkwrap and arquillian-junit-container. In addition to that we need
the managed Wildfly container configuration.
The arquillian tests are configured with a arquillian.xml configuration file:
In citrus-context.xml we define the Citrus client and server components that are used during the tests.
These components are used during the tests. The EJB JavaEE application connects to those services as client during the test.
Now lets have a look at a first sample arquillian test with its Shrinkwrap JavaEE deployments.
The tests use the Arquillian and Citrus resources with annotation based injection. All resources are automatically injected to the
test before it is executed.
This is how we can integrate Citrus with Arquillian. Both frameworks cooperate with each other in order to make JavaEE applications testable
with automated in-container deployments.
You can run the tests by calling
You should see Citrus performing several tests with lots of debugging output in the terminal. And of course green tests
at the very end of the build.