O'Reilly logo

Mastering Apache Camel by Jean-Baptiste Onofré

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required