Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
README.md
pom.xml

README.md

Sample - Arquilian - What You Test Is What You Run

Purpose of this sample

The purpose of this sample is to show you how to test an EJB in several ways :

  • Unit testing with Mockito
  • Integration testing with the standard EJBContainer of the EJB 3.1
  • Integration testing with Arquillian

Read more on my blog

Class diagram

image

Compile and package

Being Maven centric, you can compile and package it with mvn clean compile, mvn clean package or mvn clean install. The package and install phase will automatically trigger the unit tests. Once you have your war file, you can deploy it.

Deploy the sample

This sample has been tested with GlassFish 3.1.2 in several modes :

  • GlassFish runtime : download GlassFish, install it, start GlassFish (typing asadmin start-domain) and once the application is packaged deploy it (using the admin console or the command line asadmin deploy target/sampleArquilianWytiwyr.war)
  • GlassFish embedded : use the GlassFish Maven Plugin by running mvn clean package embedded-glassfish:run

Execute the sample

Once deployed you can call the ItemEJB REST service and see all the books in the database. You can also run some curl commands :

  • curl -X GET http://localhost:8080/sampleArquilianWytiwyr/rs/items
  • curl -X GET -H "accept: application/json" http://localhost:8080/sampleArquilianWytiwyr/rs/items

The purpose of this sample is to execute unit and integration tests. So to execute it you can run :

  • mvn test : this will execute the unit test ItemEJBTest which uses Mockito
  • mvn integration-test : this will execute both integration tests ItemEJBWithArquillianIT and ItemEJBWithoutArquillianIT
antonio goncalves
You can’t perform that action at this time.