CDI Containers

In CDI mode, the default reactor strategy is PerSuite. Test classes can override this by specifying PerClass. The PerMethod strategy is not supported for CDI containers.

 

Weld Container

Pax Exam starts an org.jboss.weld.environment.se.WeldContainer and uses the CDI BeanManager to fill all injection points of test classes instantiated by the driver.

To work with the Weld Container, you need the pax-exam-container-weld artifact and a test driver. At the moment, only pax-exam-junit4 is supported. In addition, you need (a subset of) the Java EE APIs and some logging artifacts.

<!-- Pax Exam -->
<dependency>
    <groupId>org.ops4j.pax.exam</groupId>
    <artifactId>pax-exam-container-weld</artifactId>
    <version>${exam.version}</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.ops4j.pax.exam</groupId>
    <artifactId>pax-exam-junit4</artifactId>
    <version>${exam.version}</version>
    <scope>test</scope>
</dependency>

<!-- Java EE APIs -->
<dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-atinject_1.0_spec</artifactId>
    <scope>provided</scope>
</dependency>

<!-- Logging -->
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-core</artifactId>
    <version>0.9.29</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>0.9.29</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
</dependency>