Blueprint TestingPage added by Guillaume NodetBlueprint TestingTesting 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. public class DebugBlueprintTest extends CamelBlueprintTestSupport {
@Override
protected Collection<URL> getBlueprintDescriptors() {
return Collections.singleton(getClass().getResource("camelContext.xml"));
}
@Test
public void testRoute() throws Exception {
// set mock expectations
getMockEndpoint("mock:a").expectedMessageCount(1);
// send a message
template.sendBody("direct:start", "World");
// assert mocks
assertMockEndpointsSatisfied();
}
}
Also notice the use of getBlueprintDescriptors to indicate that by default we should look for the camelContext.xml in the package to configure the test case which looks like this <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/blueprint" trace="true" autoStartup="true" > <route> <from uri="direct:start" /> <transform> <simple>Hello ${body}</simple> </transform> <to uri="mock:a" /> </route> </camelContext> </blueprint>
Change Notification Preferences
View Online
|
Add Comment
|
- [CONF] Apache Camel > Blueprint Testing confluence
- [CONF] Apache Camel > Blueprint Testing confluence
- [CONF] Apache Camel > Blueprint Testing confluence
- [CONF] Apache Camel > Blueprint Testing confluence
