private static final String TEST_BLUEPRINT_XML = "camel-context-for-route-blueprint.xml,OSGI-INF/blueprint/blueprint.xml";
@Override protected String getBlueprintDescriptor() { return TEST_BLUEPRINT_XML; } Then create the camel context in your test resources directory and set up whatever route or routes you want. On Tue, May 31, 2016 at 2:59 PM, souciance <souciance.eqdam.ras...@gmail.com > wrote: > I am not sure I understand completely your requirement but I have done > something like this for my unit tests. > > 1. I created a separate blueprint.xml where only necessary routes are > created in the routebuilder ref statements. Other routes are not started. > 2. In my @Before I do some advice with stuff and remove certain parts of a > route not wanted and then add the route to my context. > 3. Start the context. > > This way, you can make remove dependencies to other stuff like amqp > provider and only start routes when you need and also remove parts of a > route to mock certain responses. > > > On Tue, May 31, 2016 at 8:02 PM, owain [via Camel] < > ml-node+s465427n5783323...@n5.nabble.com> wrote: > > >  > > > > > > 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. > > > > > > > > > > > > ------------------------------ > > If you reply to this email, your message will be added to the discussion > > below: > > > > > http://camel.465427.n5.nabble.com/It-IS-possible-to-import-routeContext-in-OSGi-Blueprint-tp5783323.html > > To start a new topic under Camel - Users, email > > ml-node+s465427n465428...@n5.nabble.com > > To unsubscribe from Camel - Users, click here > > < > http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=465428&code=c291Y2lhbmNlLmVxZGFtLnJhc2h0aUBnbWFpbC5jb218NDY1NDI4fDE1MzI5MTE2NTY= > > > > . > > NAML > > < > http://camel.465427.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml > > > > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/It-IS-possible-to-import-routeContext-in-OSGi-Blueprint-tp5783323p5783325.html > Sent from the Camel - Users mailing list archive at Nabble.com.