Testing applications using Apache Camel

16
Testing Applications Using Apache Camel Rosen Spasov, Software AG Atanas Shindov, Software AG

Transcript of Testing applications using Apache Camel

Testing Applications Using Apache CamelRosen Spasov, Software AG

Atanas Shindov, Software AG

Agenda• Test Kit Overview• Simple testing with JUnit• Testing with Spring• Testing with Blueprint• Q & A

Test Kit Overview• Testing Mechanisms

– camel-test– camel-testng– camel-test-spring– camel-test-blueprint

http://camel.apache.org/testing.html

Simple Testing• You need the camel-test module• Your test should extend the CamelTestSupport class and…• Typically you will need to override the createRouteBuilder() method• JNDI Registry

http://camel.apache.org/camel-test.html

Live Demo

JNDI Registry

Mocking Existing Endpoints

Live Demo

Message Driven Consumer

http://camel.apache.org/spring-testing.html

Spring Testing• You need the camel-test-spring module• Use the @RunWith(SpringJUnit4ClassRunner.class) annotation• Provide your configuration using an XML file…

– src/test/java/org/istabg/camel/examples/SpringFilterTest.java– src/test/java/org/istabg/camel/examples/SpringFilterTest-context.xml

• or use the Java DSL with a configuration loader

http://camel.apache.org/spring-testing.html

Live Demo

Blueprint Testing• You need the camel-test-blueprint module• Your test should extend the CamelBlueprintTestSupport class and…• Specify the Blueprint descriptor location

http://camel.apache.org/blueprint-testing.html

Live Demo

Testing Endpoints• Mock – Allows assertions to be added to an endpoint.• Test – Pulls expected message bodies from an endpoint, e.g. file.• DataSet – Used for load & soak testing.

Thank You!

Atanas Shindov

Software Engineer, Software AG

Q&A