Karaf Container
The karaf test container allows to run OSGi tests inside a real Apache Karaf container. It was added to pax exam in version 3.1.0.
Upgrading from Karaf's own container
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 toorg.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 byorg.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.
pom Dependencies
Depends maven plugin
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.
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.
- The config above defines a karaf 3 container. Which is unpacked to target/exam/<guid>.
- The features option allows to install karaf feature repositories and features.
- Besides features it is also still possible to install simple bundles.
For the full test refer to CalculatorITest.
More Details
This section will be completed step by step. For the time being, please take at look at the original Karaf documentation for more details.