Hi In your route using Java DSL, you need to declare the id of the route in the DSL using .routeId("foo")
eg from("file:foo").routeId("foo") .to("blah") Then you can refer to the route id "foo" in the advice with. On Mon, Jun 25, 2012 at 9:21 AM, Hilde <hilde.sch...@yahoo.de> wrote: > Hello folks! > > When I test a existing route i prefer to work with AdviceWith. However it is > not possible to get the Route Definition over the ID, but also only via the > index in the collection. That way however is bad for readability. > > That doesn't work: > @Test > public void testMainRoutePass() throws Exception { > > context.getRouteDefinition("dkflsd").adviceWith(context, new > AdviceWithRouteBuilder() { > @Override > public void configure() throws Exception { > weaveAddLast().to("mock:mainRoute"); > } > }); > ... > > But that works instead: > @Test > public void testMainRoutePass() throws Exception { > > context.getRouteDefinitions().get(0).adviceWith(context, new > AdviceWithRouteBuilder() { > @Override > public void configure() throws Exception { > weaveAddLast().to("mock:mainRoute"); > } > }); > ... > > Here comes the camel-context.xml: > > <bean id="mainRoute" > class="com.routes.MainRoute"> > <property name="endpointTo" ref="endpointToTestImpl" /> > </bean> > > <camel:camelContext> > > <camel:routeBuilder ref="mainRoute" id="dkflsd"/> > ... > </camel:camelContext> > > > Could you help me? > > Cheers > Hilde > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Testing-routes-Get-route-definition-by-id-gets-null-tp5715014.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- FuseSource Email: cib...@fusesource.com Web: http://fusesource.com Twitter: davsclaus, fusenews Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen