Mock Extension

Mock is the first extension of the Babel Camel DSL. It provides both a DSL and some helpers.


An extension for Babel Camel declaring some helpers for testing.


The babel-camel-mock module needs to in the classpath.


Import the io.xtech.babel.camel.mock._ package and extends the RouteBuilder with the Mock trait.

mock component

For testing a mock endpoint can be declared with the mock endpoint.

import io.xtech.babel.camel.mock._

//The Mock extension is added simply by
//  extending the RouteBuilder with
val routeDef = new RouteBuilder with Mock {
  //the mock keyword is the same as typing
  //  to("mock:output1")
    //the mock keyword keeps the same body type (here: String)
    processBody(x => x.toUpperCase).


The mock keyword keeps the type of the payload as the mock component do not modify the received messages in most of the cases. For more complexe cases, such as when using returnReplyBody, you may fallback to the legacy way to define mock endpoints.