Java Reference
In-Depth Information
This integration test checks that the Configuration Admin Service implementation
successfully records configuration data that is registered before the managed bundle
starts. The managed bundle is the bundle being configured. The test method has the
standard JU nit 4 annotation and extends a base class called ConfigurationTestBase
that provides general helper methods. One such method is used to set configuration
data using the current Configuration Admin Service B . The test creates and installs a
managed bundle on the fly and waits for the configuration to be delivered to this
managed bundle. It makes sure the delivered configuration is correct C before
removing the configuration. The test waits for the managed bundle to be notified
about this removal and verifies it was correctly notified D .
T h i s i s a c l e a r t e s t . I t a l m o s t l o o k s l i k e a u n i t t e s t , e x c e p t c a l l s a r e b e i n g m a d e b e t w e e n
components instead of inside a single component or class. The other tests under the it
subproject follow the same basic pattern, which may be repeated several times:
Check the initial system state.
1
Disrupt the state (by calling services, or adding or removing bundles).
2
Check the resulting system state.
3
As you just saw, the Configuration Admin Service integration tests all extend a single
base class called ConfigurationTestBase that defines helper methods to deal with
configurations, synchronize tests, and create additional bundles at execution time.
These additional bundles consume and validate the configuration data. Right now,
the tests are only configured to run on Apache Felix, but let's see if they also pass on
other frameworks.
Add the following lines to the Pax Exam options inside the configuration()
method in ConfigurationTestBase , just as you did with the container test back in sec-
tion 7.3.2, like this:
@Configuration
public static Option[] configuration() {
return options(
frameworks(felix(), equinox(), knopflerfish()),
provision(
bundle(new File("bundles/configadmin.jar").toURI().toString()),
mavenBundle(
"org.ops4j.pax.swissbox", "pax-swissbox-tinybundles", "1.0.0"))
);
}
Pax Exam now runs each test three times—once per framework. You can see this by
typing the following command in the chapter07/testing-example/ directory:
$ ant test.integration
...
[junit] Tests run: 6, Failures: 0, Errors: 0, Time elapsed: 84.585 sec
...
[junit] Tests run: 21, Failures: 0, Errors: 0, Time elapsed: 99.05 sec
...
[junit] Tests run: 45, Failures: 0, Errors: 0, Time elapsed: 220.184 sec
Search WWH ::




Custom Search