Testing commands with Apache Karaf
After you've gone through the first two recipes, you should be set for thorough testing of OSGi bundles, either standalone or in Apache Karaf. When working with Apache Karaf, it is sometimes necessary to also have new commands. This recipe will cover how to test with commands and make sure these commands are executed inside the Apache Karaf shell.
Getting ready
It's best to have gone through the Testing Apache Karaf features recipe before starting this recipe, as this one is a follow up. The sources can be found at https://github.com/jgoodyear/ApacheKarafCookbook/tree/master/chapter10/chapter10-recipe3.
How to do it...
To test the execution of an Apache Karaf shell command, you need to tweak the test class. First, you need to alter the way the test is run. For this, we add the probe builder which configures the way the test bundle is built. Consider the following code:
@ProbeBuilder public TestProbeBuilder probeConfiguration(TestProbeBuilder probe...