![](https://link.nylas.com/open/ez36v71u7uh7qiundny4ougdd/local-2413efdb-c652)

Just come across this article  https://access.redhat.com/solutions/259293 and
it something not easily found in the community.
http://camel.465427.n5.nabble.com/camel-blueprint-unit-tests-td5738925.html
and http://camel.apache.org/how-do-i-import-routes-from-other-xml-files.html  

  
So I have just split a small camelContext into three files thinking that this
would make unit testing easier (and faster) by not having to load all of the
routes and stopping/mocking the ones you are not actually testing.  So that we
can aim for a TestClass for each of the separate routeContexts.  
  
However, if you set this up as below

  

 <camelContext id="i4ip-order"
xmlns="http://camel.apache.org/schema/blueprint">  
   <routeContextRef ref="i4ip-order-hello"/>  
   <routeContextRef ref="i4ip-order-hipchat"/>  
 </camelContext>  
  
</blueprint>  
  
You are unable to just getBluePrintDescriptor of the individual route as you
still need a camelContext which doesn't really get any closer to the
individual route per unit test class.  
~~~  
 @Override  
 protected String getBlueprintDescriptor() {  
   return "/OSGI-INF/blueprint/i4ip-order-hello-route.xml";  
 }  
~~~  
  
all of the Blueprint routeContext  files reside is in the same blueprint
directory as the "production" camelContext for this bundle.  It is the id and
ref that link them together.  
  
~~~  
 <routeContext id="i4ip-order-hello"
xmlns="http://camel.apache.org/schema/blueprint">  
  
   <route id="i4ip-order-hello">  
     <from id="fromTimer" uri="timer:foo?period=5000"/>  
     <setBody id="invokeHelloBean">  
       <method ref="helloBean" method="hello"/>  
     </setBody>  
     <log message="The message contains ${body}"/>  
     <to uri="seda:hipchatMessages" id="toHipchat"/>  
   </route>  
  
 </routeContext>  
~~~  
  

I don't want to have each routeContext in its own camelContext since that
precludes seda and direct endpoints.

  

Is there a way around this, like weave a "temporary" context around the
routeContext just for unit testing.  I have had a play with this but I think I
have to have a "context" every time.

  

The other option I was thinking of was to use RouteBuillder to create a
CamelContext then for it to pull in the relevant ref for the routeContext.

  

Has anyone had any success with this or think of a better approach.

  

Thanks,

  

O.

  

Reply via email to