Hi See the advice with section in the testing guide. Also there is a stub endpoint you can use to stub a real component. You can then the stub component to shadow hibernate etc.
On Fri, Jul 3, 2015 at 10:26 AM, Coombes Paul (RTH) OUH <paul.coom...@ouh.nhs.uk> wrote: > 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 > > > -- Claus Ibsen ----------------- Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/