Java Reference
In-Depth Information
[junit] Installed and started:
file:bundles/org.ops4j.pax.exam_1.1.0.jar (id#1)
[junit] Installed and started:
file:bundles/org.ops4j.pax.exam.junit.extender_1.1.0.jar (id#2)
[junit] Installed and started:
file:bundles/org.ops4j.pax.exam.junit.extender.impl_1.1.0.jar (id#3)
[junit] Installed and started:
file:bundles/org.ops4j.pax.url.dir_1.0.0.jar (id#4)
[junit] Installed and started:
file:bundles/com.springsource.org.junit_4.4.0.jar (id#5)
[junit]
[junit] Installed and started:
file:bundles/org.ops4j.pax.exam.rbc_1.1.0.jar (id#6)
[junit] Installed and started:
file:bundles/osgi.cmpn_4.2.0.200908310645.jar (id#7)
[junit] Framework launched
[junit] org.osgi.framework.vendor = Knopflerfish
[junit] org.osgi.framework.version = 1.3
[junit] org.osgi.framework.language = en
[junit] org.osgi.framework.os.name = Windows Vista
[junit] org.osgi.framework.os.version = 6.0
[junit] org.osgi.framework.processor = x86
[junit]
[junit] Test Bundle is pax-exam-probe
[junit]
[junit]
[junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 12.513 sec
Notice how some of the properties vary slightly between frameworks, in particular the
OS name. This is a reminder of why it's a good idea to test on a variety of frameworks:
to make sure you aren't depending on unspecified or undocumented behavior.
You just saw how easy it is to run a test on many different frameworks using Pax
Exam. But how well does it work with existing unit tests and existing test tools?
7.3.3
Unit testing
At the start of this section, we mentioned how OSG i test tools can help you modularize
and manage tests. Because Pax Exam integrates with JU nit as a custom runner, you can
use it in any system that can run JU nit tests. This means you can mix non- OSG i unit
and integration tests with Pax Exam-based tests and have the results collected in one
place. A good example of this mixture can be found in the Configuration Admin Ser-
vice implementation from the Apache Felix project ( http://felix.apache.org/site/
apache-felix-config-admin.html ) . The Configuration Admin Service is a compendium
service that provides and persists configuration data for bundles.
The Felix Configuration Admin Service build uses Maven and has a single test
directory. This test directory contains mocked-out unit tests to test internal details
along with Pax Exam integration tests to test the expected Configuration Admin Ser-
vice behavior. We've taken these tests and separated them into unit and integration
tests so you can see the difference. The unit tests are in the ut subproject, and you can
run them with this command from the chapter07/testing-example/ directory:
Search WWH ::




Custom Search