Several utilities are provided for Java EE testing:

  • inject: general dependency injection in unit test.
  • cdi: CDI dependency injection in unit test.
  • transactions: Transaction support in unit test.
  • jndi: JNDI support in unit test.
  • persistence: JPA support in unit test.

Maven POM configuration

To configure your pom, you must configure three dependencies:

  • The general JPA test support library.
  • A JPA implementation-specific library.
  • The dependency on your specific JPA provider.

The above 'three stage rocket' is necessary because:

  • Customizations to the persistence unit for different JPA providers might conflict and might require additional JPA provider specific dependencies.
  • Different JPA providers can, in general, not be used within the same application. (an exception is of course an OSGI environment when JPA is used as per the OSGI enterprise spec).
  • The specific JPA implementation and version to use must be determined by you and not by the test support library.
Note: This library includes the JSF API (1.2) as a transitive dependency. This is required to get CDI support working in a Java SE environment. If you are using a different version of JSF you must exclude this dependency and/or override it.

The general JPA test support library

Always include the dependency below:

groupId artifactId
org.wamblee wamblee-test-enterprise

JPA implementation-specific library

Choose one from the choices below:

Provider groupId artifactId
Eclipse link org.wamblee wamblee-test-eclipselink
Toplink org.wamblee wamblee-test-toplink-essentials
Hibernate (from 3.4.0.GA and higher). org.wamblee wamblee-test-hibernate