Java Reference
In-Depth Information
middle, isn't something the normal JU nit test runner is designed to handle. You'll
need to run with a special Pax Exam runner instead by adding a class-level annotation:
Pax Exam can also inject a bundle context into your test class:
import javax.inject.Inject;
protected BundleContext ctx;
WARNING: WHY IS NOTHING BEING INJECTED? If you're using Pax Exam injec-
tion, make sure to use the javax.inject.Inject annotation and not
org.ops4j.pax.exam.Inject . The Pax Exam annotation is nonfunctional in
Pax Exam 2.0 and up.
It's a good pattern to use the bundle context for querying the state of the framework,
but to use Pax Exam's API to configure the framework and install bundles.
Pax Exam configuration of the framework is done in a method annotated @Configu-
ration . Pax Exam provides a fluent API for building up configuration options and
gives you detailed control over the contents and configuration of your OSG i frame-
work. You can specify the OSG i framework implementation (Equinox, Felix, Knop-
flerfish) and version, or any combination of implementations and versions, system
properties, and installed bundles. You can specify a list of bundles to install, as well as
JVM options, and OSG i frameworks. All of these can be controlled using methods stati-
cally imported from org.ops4j.pax.exam.CoreOptions and combined into an array
using the CoreOptions.options() method:
public static Option[] configuration() {
MavenArtifactProvisionOption foodGroup = mavenBundle().groupId(
Option[] fancyFoodsBundles = options(
Option[] server = PaxConfigurer.getServerPlatform();
Option[] options = OptionUtils.combine(fancyFoodsBundles,
return options;
Here you're installing the fancyfoods.department.cheese bundle, along with its
dependencies and the bundles that make up the hosting server. Most of your tests will
Search WWH ::

Custom Search