3

I am attempting to integration test a Karaf feature with Pax Exam but I cant work out how to install a feature in my config() method.

Pax Exam is version 2.6.0 and Apache Karaf 2.3.2.

This is my config method:

@Configuration
public Option[] config() {
    return new Option[]{karafDistributionConfiguration().frameworkUrl(
            maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("zip").versionAsInProject())
            .karafVersion("2.3.2").name("Apache Karaf").unpackDirectory(new File("target")),
            keepRuntimeFolder()};
}

Individual bundles can be installed with mavenBundle("group", "artifact", "version") but there seems to be no mechanism to install a Karaf feature with Pax Exam.

I am able to install features pragmatically in a setup method annotated with Junit @Before but it too late to get my services injected with @Inject.

Is it possible to install Apache Karaf Features in the config() method of a Pax Exam Test?

samlewis
  • 3,950
  • 27
  • 27

1 Answers1

9

First of all I strongly suggest to use the latest version of Pax-Exam (3.3.0), it does provide Karaf support out of the box. Second you're able to install features directly in the config() method. For example:

features(maven().groupId("org.apache.karaf.assemblies.features")
       .artifactId("standard").type("xml").classifier("features")
       .versionAsInProject(), "http-whiteboard")

You'll find a working sample at my github

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22