Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device.
Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
The Pax Exam Karaf Test Container is based on and supersedes the Karaf Exam test container from the Apache Karaf codebase. The Apache Karaf and Pax Exam communities both agreed that the Karaf test container would be easier to maintain as a Pax Exam module, so Pax Exam 3.1.0 is the first release to incorporate the Karaf test container, using Karaf 3.0.0.RC1 as a starting point.
Packages org.apache.karaf.tooling.exam.* have been renamed to org.ops4j.pax.exam.karaf.*.
The scanFeatures() option method for provisioning Karaf features which was dropped in Pax Exam 3.0.0 along with the Pax Runner Container has been superseded by org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features()
Getting started
The fastest way to start is to copy the exam-itest-sample-karaf and adapt it to your needs. This example will be explained in this getting started guide.
Bundle and feature versions can be refered to with versionAsInProject() instead of specifying a concrete version number. This requires to add the depends maven plugin to your build. You will also have to specify a maven dependency for every bundle or feaure your refer in this way.
<build>
<plugins>
<!-- Needed if you use versionAsInProject() -->
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>generate-depends-file</id>
<goals>
<goal>generate-depends-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
A basic Test
Tests using the karaf test container are similar to other pax exam OSGi tests. The main difference is that you need to specify the karaf container to run with and have some additional options using KarafDistributionOption.