Testing Apache Camel 3.13.x in SpringBoot application in examples

  1. Apache Camel gives you a DSL (Domain Specific Language) that helps you to describe how the data should be transformed.
  2. Apache Camel has over 330 different connectors, by means of which you could easily gather your data and deliver it wherever it needs.
  3. Apache Camel provides you a mechanism of thread manipulation under the hood to process any job in parallel.
Schema describing data transformation of superseding bad words with good ones in every incoming file
Spring Boot bean to implement Camel Route — I like such charm. By the way you should not write such comments.
notice this class is not for tests
this class is for tests only — it is placed into src/test/java path
  1. Test is annotated with @SpringBootTest and@CamelSpringBootTest both
  2. @SpringBootTest has classes property specified with Application class
  3. In test method mocked endpoint is adjusted with several expectations
  4. After a message is sent into from-endpoint the mocked endpoint checks all caught messages on expectations to be satisfied
$ echo "123 duck
456 luck
789 duck tales" > /tmp/in/test
incoming file has been processed
$ cat /tmp/out/test
123 ostrich
456 luck
689 ostrich tales
it needs to add dependency for HTTP Camel component, but it is not necessary for testing
segregating production and test external service — mock it in test
route definition use endpoint definition provided by property provider
I advice Camel to set a concrete body instead of calling supervisor service
enabling Advice mechanism
camelContext.start(); // start CamelContext explicitly
// perform test - send a message into route
camelContext.stop(); // stop CamelContext explicitly
notice that Camel Context is not started automatically



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vyacheslav Boyko

Vyacheslav Boyko

Software developer, writing in Java. Over 15 years in IT. Enthusiast in EDA, Microservices, Integrations, experiencing in finance, trading, banking. He/Him.