OPS4J Pax Exam 4.xConcepts


Operation Mode

Pax Exam 3.x supports four operation modes OSGi, Java EE, CDI and Web. OSGi is the default mode and the only one available in Pax Exam 2.x.

OSGi Mode

In OSGi mode, Pax Exam starts a test container with an OSGi framework, lets you provision bundles by configuration options and builds a probe bundle from the test classes and resources of your current project.

Java EE Mode

In Java EE mode, Pax Exam starts a Java EE application server, deploys WAR modules defined in configuration options and builds a WAR probe from the contents of the current class path. The WAR probe includes your test cases which are invoked by the driver via a servlet bridge. The tests are executed within the Java EE container, the test results are returned to the driver as a HTTP result.

CDI Mode

In CDI mode, Pax Exam starts a CDI container in the current VM, providing the subset of CDI functionality which does not require a Java EE environment. CDI mode does not use probes, all tests are directly invoked by the driver after injecting dependencies using the CDI bean manager.

Web Mode

In Web mode, Pax Exam starts a servlet container in the current VM. This mode supports web-only containers like Tomcat or Jetty, using either CDI or Spring for dependency injection.


In the context of Pax Exam (OSGi mode), the term framework usually refers to the OSGi framework running the system under test.

System under test

The system under test is the collection of your application and library bundles.

Pax Exam aims at executing black box tests, but in fact the box (i.e. the container) is slightly grey, as Pax Exam adds some bundles of its own and the probe.

Test Container

The test container is a thin wrapper around the framework, the system under test and the probe\, adding the ability to communicate with the driver and the outside world in general.


The reactor manages the collection of all tests to be executed in one or more different containers. The reactor starts and stops the required containers and provisions bundles and probes to the containers.


The driver is the entry point into Pax Exam. It evaluates configuration options and creates a reactor based on these options. The driver receives the test results and handles them in an implementation dependent way.

Pax Exam includes different drivers:

  • The JUnit driver integrates Pax Exam with JUnit.
  • The TestNG driver integrates Pax Exam with TestNG.
  • The Pax Exam Player provides a simple low-level API for running tests.


The probe is a synthetic artifact which Pax Exam adds to the system under test.

In OSGi mode, Pax Exam creates the probe on the fly with the help of Tinybundles. The probe contains the current test class and all classes and resources found under the same root.

In Java EE or Web mode, the probe is a WAR containing all test classes, resources and dependencies on the classpath, the servlet bridge and some other Pax Exam dependencies.

In CDI mode, there is no probe, all test methods are invoked directly.


The configuration determines the set of bundles or modules provisioned to the container, and some system and environment properties.

There are different methods of specifying configuration options. In OSGi mode, you typically use one or more methods annotated by @Configuration with return type Option[].

In the other modes, the test container is automatically configured from the contents of the class path.

If you need to customize the contents of the WAR probe in Java EE or Web mode, you can override the defaults in a @Configuration method.