Dear Camel Guru's I have a query regarding testing of a Java DSL route and how to effectively mock endpoints.
I have a SpringRouteBuilder (see following) that polls a database table via the hibernate component, with the results being split into individual result items which are transformed into an HAPI HL7 Message via a custom processor before being sent to a HL7 receiver via a Mina2 endpoint. Having looked over the testing documentation and not seeing an immediately obvious answer, my question is, how best to test a routes logic whilst mocking the producer and consumer endpoints (Hibernate and Mina2 respectively) without duplicating the route logic in a Junit test? HL7RouteBuilder from("hibernate:HibernateModel?consumeDelete=false&consumer.query=FROM HibernateModel WHERE processed = 'N'") .split(simple("body")) .log(LoggingLevel.DEBUG, "my.logger", "Transforming HibernateModel ${body.id}") .to("direct:toHL7"); from("direct:toHL7") .onException(new Class[] { java.lang.Exception.class }) .log(LoggingLevel.ERROR, " my.logger", "Failed to generate ORU^R01 ${body.id} - ${exception.stacktrace}") .stop() .end() .log(LoggingLevel.DEBUG, "my.logger", "Transforming HibernateModel ${body.id} into HLv2 ORU^R01") .processRef("modelProcessor") .marshal().hl7(false) .to("mirthV2StoreOut"); Camel Spring Configuration <camel:endpoint id="mirthV2StoreOut" uri="mina2:tcp://${listen.host}:${listen.port}?codec=#hl7codec"/> <camel:camelContext id="integrationEngineInCamelCtx"> <camel:routeBuilder ref="HL7RouteBuilder" /> </camel:camelContext> <bean id="HL7RouteBuilder" class="HL7RouteBuilder" scope="prototype"/> Kind Regards, Paul