Java Reference
In-Depth Information
shouting at an innocent laptop, “Where's my bundle? And why won't you tell me that
six bundles in my framework failed to start?” at the end of a long day's testing.
If you're planning to deploy your enterprise
OSG
i application on one of the bigger
and more muscular application servers, you may find that it's more application server
than you need for your integration testing. In this case, you may be better off prepar-
ing a sandbox environment for testing, either by physically assembling one, or by
working out the right minimum set of dependencies.
The Aries assembly you've been using to run the examples through the course of
the topic is a good example of a hand-assembled
OSG
i runtime. You've started with a
simple Equinox
OSG
i framework and added in the bundles needed to support the
enterprise
OSG
i programming model. Alternatively, there are several open source
projects that aim to provide lightweight and flexible
OSG
i runtimes.
PAX RUNNER
Pax Runner is a slim container for launching
OSG
i frameworks and provisioning bun-
dles. We've already met Pax Runner in section 8.3.2 because Pax Exam relies heavily
on Pax Runner to configure and launch its
OSG
i framework. You may find it easier to
bypass Pax Exam and use Pax Runner directly as a test environment. Pax Runner
comes with a number of predefined profiles, which can be preloaded into the frame-
work. For example, to launch an
OSG
i framework that's capable of running simple
web applications, it's sufficient to use this command:
pax-run.sh --profiles=web
At the time of writing, there isn't a Pax Runner profile that fully supports the enter-
prise
OSG
i programming model. But profiles are text files that list bundle locations, so
it's simple to write your own profiles. These profiles can be shared between members
of your development team, which is nice, and fed to Pax Exam for automated testing,
which is even nicer. Pax Runner also integrates with Eclipse
PDE
, so you can use the
same framework in your automated testing and your development-time testing:
pax-run.sh --file:///yourprofile.txt
Although Pax Runner is described as a provisioning tool, it can't provision bundles
like the provisioners we discussed in chapter 7. You'll need to list every bundle you
want to include in your profile file.
KARAF
An alternative to Pax Runner, with slightly more dynamic provisioning behavior, is
Apache Karaf. Like the name implies, Karaf is a little
OSG
i container. Karaf has some
handy features that are missing in Pax Runner, like hot deployment and runtime pro-
visioning. This functionality makes Karaf suitable for use as a production runtime,
rather than as a test container. Karaf is so suitable for production, it underpins the
Apache Geronimo server. But Karaf isn't as well integrated into existing unit test
frameworks as Pax Runner, so if you use Karaf for your testing you'll mostly be limited
to the “use
JU
nit to scrape test result logs” approach we described above.