Mocking OSGi services
The Camel Blueprint test kit allows you to mock and prototype OSGi services.
For that, the kit uses the PojoSR
library.
For instance, we want to test the following route:
<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <reference id="service" interface="org.apache.camel.Processor"/> <camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route id="test"> <from uri="direct:input"/> <process ref="service"/> <to uri="direct:output"/> </route> </camelContext> </blueprint>
If this route is very simple, it uses an OSGi service via the <reference/>
element. In the OSGi container, the reference element is looking for the actual service in the OSGi Service Registry.
Instead of using a real blueprint container, the Camel Blueprint test kit allows you to register services...