Design and Architecture
Pax Exam has the notion of a Test Container which is defined as
Management of an OSGi framework that can be used as a integration test container.
Pax Exam generates a Bundle on-the-fly out of your Test Classes.
Test Container
A Test Container defines hooks for instrumenting such a platform.
It includes
- starting and stopping the platform
- provisioning of bundles
- service discovery
A Test Container can provide extra Configuration Options so that tighs the Test to a specific container but makes best usage and easy configuration possible.
Default Test Container - Pax Runner
PaxRunnerTestContainer comes with pax exam and can be added to your project as follows:
<dependency> <groupId>org.ops4j.pax.exam</groupId> <artifactId>pax-exam-container-default</artifactId> <version>(version of choice)</version> </dependency>
This container makes full use of PaxRunner's capabilities to provide+start all leading OSGi framework implementations
- Apache Felix
- Eclipse's Equinox
- Knopflerfish
Because of that, Pax Runner Test Container is very likely to be your implementation of choice.
This is why we call this container implementation Default Pax Exam Test Container (see maven artefactId).
Configuration
In general, most of pax runner's configuration options are provided as a dense, humane api.
Here is a short example
# pax.run file:/foo/bar.jar@noStart@update@startLevel=10
@Configuration public static Option[] configureBundleScanner() { return options( scanBundle( "file:/foo/bar.jar" ).noStart().update().startLevel( 10 ) ); }
Runtime Specifics of Pax Runner Test Container
Pax Runner is a osgi starter that
1. Downloads a specified runtime
2. Generates the framework specifc configuration
3. Generates a complete Command Line to start the desired framework with proper configuration
4. Starts a new Java VM Process just as configured, including version, bootclasspath and so on. (See .. for more)
Pax Exam will do just the same.
Before starting the process, Pax Exam finds a free network port and knows that after starting the new process that there will be a RMI registry running on that port.
A single RMI call is used to invoke a specific Test in that "remote" VM Process and collect the outcome.
All System Streams (System.out, System.err, System.in) are piped to the parent process' equivalents.
Bundle on the fly
Regardless of your test container choice, pax exam will generate a bundle out of your test classes.
This is implemented in a special Pax-URL Handler called pax-url-dir
(include pax url dir doc here)