Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Blueprint Testing

Available as of Camel 2.10

Testing is a crucial part of any development or integration work. Camel supports the definition of Blueprint routes, but given Blueprint is an OSGi specific technology, writing unit tests is quite difficult. This library leverages PojoSR which provides a service registry without using a fully compliant OSGi container. This allows defining real unit tests (as opposed to integration tests using Pax Exam.

Here is an example using XML Config.

Wiki Markup
{snippet:lang=java|id=example|url=camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java}

Also notice the use of getBlueprintDescriptor to specify the location of the OSGi Blueprint XML file.
If you have multiple OSGi Blueprint XML files, then you can specify them separated by comma in the getBlueprintDescriptor method.

And the Blueprint XML file. And link to the full file here

Wiki Markup
{snippet:lang=xml|id=example|url=camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/camelContext.xml}

...

In order to define blueprint tests, you need to add the following dependency in your pom:

Code Block
xml
xml
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-test-blueprint</artifactId>
  <version>2.10-SNAPSHOT<10</version>
  <scope>test</scope>
</dependency>