You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2017/08/25 08:22:03 UTC

svn commit: r1017260 [1/40] - in /websites/production/camel/content: ./ cache/

Author: buildbot
Date: Fri Aug 25 08:22:01 2017
New Revision: 1017260

Log:
Production update by buildbot for camel

Modified:
    websites/production/camel/content/advicewith.html
    websites/production/camel/content/aggregator2.html
    websites/production/camel/content/async.html
    websites/production/camel/content/bam.html
    websites/production/camel/content/beanshell.html
    websites/production/camel/content/blueprint-testing.html
    websites/production/camel/content/book-component-appendix.html
    websites/production/camel/content/book-cookbook.html
    websites/production/camel/content/book-dataformat-appendix.html
    websites/production/camel/content/book-in-one-page.html
    websites/production/camel/content/book-languages-appendix.html
    websites/production/camel/content/book-pattern-appendix.html
    websites/production/camel/content/book-quickstart.html
    websites/production/camel/content/book-tutorials.html
    websites/production/camel/content/cache/main.pageCache
    websites/production/camel/content/camel-jmx.html
    websites/production/camel/content/camel-test.html
    websites/production/camel/content/camel-transport-for-cxf.html
    websites/production/camel/content/claim-check.html
    websites/production/camel/content/configuring-camel.html
    websites/production/camel/content/console-example.html
    websites/production/camel/content/content-enricher.html
    websites/production/camel/content/cxf-example.html
    websites/production/camel/content/cxf-proxy-example.html
    websites/production/camel/content/cxfrs.html
    websites/production/camel/content/debugger.html
    websites/production/camel/content/delayer.html
    websites/production/camel/content/dynamic-router.html
    websites/production/camel/content/error-handler.html
    websites/production/camel/content/exception-clause.html
    websites/production/camel/content/graceful-shutdown.html
    websites/production/camel/content/groovy.html
    websites/production/camel/content/header.html
    websites/production/camel/content/hl7.html
    websites/production/camel/content/how-do-i-add-a-component.html
    websites/production/camel/content/how-do-i-configure-endpoints.html
    websites/production/camel/content/how-do-i-import-routes-from-other-xml-files.html
    websites/production/camel/content/idempotent-consumer.html
    websites/production/camel/content/intercept.html
    websites/production/camel/content/javascript.html
    websites/production/camel/content/jcifs.html
    websites/production/camel/content/json.html
    websites/production/camel/content/jxpath.html
    websites/production/camel/content/load-balancer.html
    websites/production/camel/content/loop.html
    websites/production/camel/content/normalizer.html
    websites/production/camel/content/oncompletion.html
    websites/production/camel/content/php.html
    websites/production/camel/content/pojo-messaging-example.html
    websites/production/camel/content/polling-consumer.html
    websites/production/camel/content/property.html
    websites/production/camel/content/python.html
    websites/production/camel/content/quickfix.html
    websites/production/camel/content/recipient-list.html
    websites/production/camel/content/redeliverypolicy.html
    websites/production/camel/content/route-throttling-example.html
    websites/production/camel/content/routing-slip.html
    websites/production/camel/content/ruby.html
    websites/production/camel/content/sampling.html
    websites/production/camel/content/scala-dsl-eip.html
    websites/production/camel/content/scala-dsl-getting-started.html
    websites/production/camel/content/scala-dsl-supported-languages.html
    websites/production/camel/content/scripting-languages-context.html
    websites/production/camel/content/scripting-languages.html
    websites/production/camel/content/siteindex.html
    websites/production/camel/content/spring-java-config-example.html
    websites/production/camel/content/spring-security.html
    websites/production/camel/content/spring-testing.html
    websites/production/camel/content/springintegration.html
    websites/production/camel/content/sql-example.html
    websites/production/camel/content/stringtemplate.html
    websites/production/camel/content/testing.html
    websites/production/camel/content/throttler.html
    websites/production/camel/content/tracer-example.html
    websites/production/camel/content/tracer.html
    websites/production/camel/content/transactional-client.html
    websites/production/camel/content/try-catch-finally.html
    websites/production/camel/content/tutorial-jmsremoting.html
    websites/production/camel/content/urlrewrite.html
    websites/production/camel/content/using-camelproxy.html
    websites/production/camel/content/validation.html
    websites/production/camel/content/walk-through-an-example.html
    websites/production/camel/content/why-is-my-processor-not-showing-up-in-jconsole.html
    websites/production/camel/content/wire-tap.html
    websites/production/camel/content/xpath.html
    websites/production/camel/content/xstream.html

Modified: websites/production/camel/content/advicewith.html
==============================================================================
--- websites/production/camel/content/advicewith.html (original)
+++ websites/production/camel/content/advicewith.html Fri Aug 25 08:22:01 2017
@@ -36,17 +36,6 @@
     <![endif]-->
 
 
-  <link href='//camel.apache.org/styles/highlighter/styles/shCoreCamel.css' rel='stylesheet' type='text/css' />
-  <link href='//camel.apache.org/styles/highlighter/styles/shThemeCamel.css' rel='stylesheet' type='text/css' />
-  <script src='//camel.apache.org/styles/highlighter/scripts/shCore.js' type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
-  <script src='//camel.apache.org/styles/highlighter/scripts/shBrushPlain.js' type='text/javascript'></script>
-  
-  <script type="text/javascript">
-  SyntaxHighlighter.defaults['toolbar'] = false;
-  SyntaxHighlighter.all();
-  </script>
 
     <title>
     Apache Camel: AdviceWith
@@ -86,155 +75,46 @@
 	<tbody>
         <tr>
         <td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="AdviceWith-AdviceWith">AdviceWith</h2><p><strong>Available as of Camel 2.1</strong></p><p>AdviceWith is used for testing Camel routes where you can <em>advice</em> an existing route before its being tested. What <strong><code>adviceWith</code></strong> allows is to changes some factors on the route before the test is being run. At the current time you can <em>advice</em> an existing route by adding <a shape="rect" href="intercept.html">Intercept</a>, <a shape="rect" href="exception-clause.html">Exception Clause</a> etc. which then will apply for the route being advice.</p><p>For example, in the route below we intercept sending a message to the <strong><code>mock:foo</code></strong> endpoint and detour the message.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-public void testAdvised() throws Exception {
-    // advice the first route using the inlined route builder
-    context.getRouteDefinitions().get(0).adviceWith(context, new RouteBuilder() {
-        @Override
-        public void configure() throws Exception {
-            // intercept sending to mock:foo and do something else
-            interceptSendToEndpoint(&quot;mock:foo&quot;)
-                    .skipSendToOriginalEndpoint()
-                    .to(&quot;log:foo&quot;)
-                    .to(&quot;mock:advised&quot;);
-        }
-    });
-
-    getMockEndpoint(&quot;mock:foo&quot;).expectedMessageCount(0);
-    getMockEndpoint(&quot;mock:advised&quot;).expectedMessageCount(1);
-    getMockEndpoint(&quot;mock:result&quot;).expectedMessageCount(1);
-
-    template.sendBody(&quot;direct:start&quot;, &quot;Hello World&quot;);
-
-    assertMockEndpointsSatisfied();
-}
-]]></script>
-</div></div><div class="confluence-information-macro confluence-information-macro-warning"><p class="title">Recommendation</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved.<br clear="none"> The Camel team plan for <strong>Camel 3.0</strong> to support this as internal refactorings in the routing engine is needed to support this properly.</p></div></div><div class="confluence-information-macro confluence-information-macro-warning"><p class="title">Recommendation</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>It's recommended to only advice routes which are not started alr
 eady. If you advice already started routes, then it may not work as expected.</p></div></div><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">Telling Camel you are using adviceWith</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>From <strong>Camel 2.9</strong>: it's recommended to override the <strong><code>isUseAdviceWith()</code></strong> method and return true to tell Camel you are using advice with in your unit tests. Then after you have done the <strong><code>adviceWith()</code></strong>, then you must start <strong><code>CamelContext</code></strong> manually. See further below for an example.</p></div></div><h3 id="AdviceWith-UsingAdviceWithRouteBuilder">Using&#160;<code>AdviceWithRouteBuilder</code></h3><p><strong>Available as of Camel 2.7</strong></p><p>The <strong><code>AdviceWithRouteBuilder</code></strong> is a specialized <st
 rong><code>RouteBuilder</code></strong> which has additional methods for advising routes. For example this allows you to manipulate the advised route, such as replacing a node with some other nodes.</p><p>The <strong><code>AdviceWithRouteBuilder</code></strong> offers the following extra methods:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpoints</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock all endpoints. See more details and examples at <a shape="rect" href="mock.html">Mock</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpoints(patterns)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock endpoints using a pattern. See more deta
 ils and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. From Camel 2.10 onwards you can specify multiple patterns.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpointsAndSkip(patterns)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock endpoints using a pattern, and <strong>skip</strong> sending to the original endpoint. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. You can specify multiple patterns.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveById(pattern)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to select node(s) matching by id's, and weave in the following nodes. See below for pattern matching and examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveByToString(pattern)</code></p></td><td colspan="1" ro
 wspan="1" class="confluenceTd"><p>Is used to select nodes(s) matching by their <strong><code>toString</code></strong> representation, and weave in the following nodes. See below for pattern matching and examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveByType(Class)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is used to select node(s) matching by their class type (the classes from the&#160;<strong><code>org.apache.camel.model</code></strong> package), and weave in the following nodes. See below for examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveAddFirst</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the start of the route.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveAddLast</code></p></td><td colspan="1" rowspan
 ="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the end of the route.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>replaceFromWith(uri)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> To replace the route input with a new endpoint URI.</p></td></tr></tbody></table></div><p>The <strong><code>pattern</code></strong> option is used for matching. It uses the same rules as the <a shape="rect" href="intercept.html">Intercept</a>, which is applied in the following order:</p><ul><li>match exact</li><li>match by wildcard</li><li>match by regular expression</li></ul><p>For example to match exact you can use&#160;<strong><code>weaveById("foo")</code></strong> which will match only the id in the route which has the value: <strong><code>foo</code></strong>. The wildcard is when the pattern ends with a&#160;<strong><code>*</code></strong> character, such 
 as:&#160;<strong><code>weaveById("foo*")</code></strong> which will match any id's starting with <strong><code>foo</code></strong>, such as: <strong><code>foo</code>, <code>foobar</code></strong>,&#160;<strong><code>foobie</code></strong> and so forth. The regular expression is more advanced and allows you to match multiple ids, such as&#160;<strong><code>weaveById("(foo|bar)")</code></strong> which will match both&#160;<strong><code>foo</code></strong> and <strong><code>bar</code></strong>.</p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>If you try to match a <code>pattern</code> on an exact endpoint URI, then mind that URI options ordering may influence, and hence its best to match by wildcard.</p><p>For example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelConte
 nt pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[mockEndpointsAndSkip(&quot;activemq:queue:foo?*&quot;)
-]]></script>
-</div></div><p>To match the&#160;<strong><code>foo</code></strong> queue and disregard any options.</p></div></div><h3 id="AdviceWith-UsingweaveById">Using&#160;<code>weaveById</code></h3><p>The <strong><code>weaveById</code></strong> allows you to manipulate the route, for example by replacing a node with other nodes.</p><p>The following methods are available:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>remove</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Removes the selected node(s).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>replace</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Replaces the selected node(s) with the following nodes.</p></td></tr><tr><td colspan="1" rowspan="1" cla
 ss="confluenceTd"><p><code>before</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Before the selected node(s), the following nodes is added.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>after</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>After the selected node(s), the following nodes is added.</p></td></tr></tbody></table></div><p>For example given the following route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Route</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[from(&quot;direct:start&quot;)
-    .to(&quot;mock:foo&quot;)
-    .to(&quot;mock:bar&quot;).id(&quot;bar&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div><p>Then let's go over the four methods to see how you can use them in unit tests:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Replace</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
-    @Override
-    public void configure() throws Exception {
-        // weave the node in the route which has id = bar
-        // and replace it with the following route path
-        weaveById(&quot;bar&quot;).replace().multicast().to(&quot;mock:a&quot;).to(&quot;mock:b&quot;);
-    }
-});
-]]></script>
-</div></div>In this example we replace the <strong><code>.to("mock:bar").id("bar")</code></strong> with the <strong><code>.multicast().to("mock:a").to("mock:b")</code></strong>.<br clear="none"> That means instead of sending the message to a <code><strong>mock:bar</strong></code> endpoint, we do a <a shape="rect" href="multicast.html">Multicast</a> to <code><strong>mock:a</strong></code> and <code><strong>mock:b</strong></code> endpoints instead.<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Remove</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
-    @Override
-    public void configure() throws Exception {
-        // weave the node in the route which has id = bar and remove it
-        weaveById(&quot;bar&quot;).remove();
-    }
-});
-]]></script>
-</div></div>In the example above, we simply just remove the <strong><code>.to("mock:bar").id("bar")</code></strong>.<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Before</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
-    @Override
-    public void configure() throws Exception {
-        // weave the node in the route which has id = bar
-        // and insert the following route path before the adviced node
-        weaveById(&quot;bar&quot;).before().to(&quot;mock:a&quot;).transform(constant(&quot;Bye World&quot;));
-    }
-});
-]]></script>
-</div></div>In the example above, we add the following nodes <strong><code>to("mock:a").transform(constant("Bye World"))</code> before</strong> the node with the id <strong><code>bar</code></strong>.<br clear="none"> That means the message being send to <strong><code>mock:bar</code></strong> would have been transformed to a constant message "<strong><code>Bye World</code></strong>".<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>After</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
-    @Override
-    public void configure() throws Exception {
-        // weave the node in the route which has id = bar
-        // and insert the following route path after the advice node
-        weaveById(&quot;bar&quot;).after().to(&quot;mock:a&quot;).transform(constant(&quot;Bye World&quot;));
-    }
-});
-]]></script>
-</div></div>In the example above, we add the following nodes <strong><code>to("mock:a").transform(constant("Bye World"))</code> after</strong> the node with the id&#160;<code><strong>bar</strong></code>.<h3 id="AdviceWith-UsingweaveByToString">Using&#160;<code>weaveByToString</code></h3><p>The <strong><code>weaveByToString</code></strong> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <strong><code>weaveById</code></strong>, this method uses the <strong><code>toString</code></strong> representation of the node(s) when matching. This allows you to match nodes, which may not have assigned ids, or to match <a shape="rect" href="eip.html">EIP</a> pattern. You have to be a bit more careful when using this as the <strong><code>toString</code></strong> representation can be verbose and contain characters such as <strong>[ ] ( )-&gt;</strong> and so forth. That is why using the regular expression matching is the must usable.</p><p>Th
 e <strong><code>weaveByToString</code></strong> has the same methods as <strong><code>weaveById</code></strong>.</p><p>For example to replace any nodes which has <code>"<strong>foo</strong>"</code> you can do</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Replace</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
-    @Override
-    public void configure() throws Exception {
-        // weave nodes in the route which has foo anywhere in their to string representation
-        // and replace them with the following route path
-        weaveByToString(&quot;.*foo.*&quot;).replace().multicast().to(&quot;mock:a&quot;).to(&quot;mock:b&quot;);
-    }
-});
-]]></script>
-</div></div>Notice that we have to use <code>".<strong>foo.</strong>"</code> in the pattern to match that <code>"<strong>foo</strong>"</code> is present anywhere in the string.<h3 id="AdviceWith-UsingweaveByType">Using&#160;<code>weaveByType</code></h3><p><strong>Available as of Camel 2.8</strong></p><p>The <strong><code>weaveByToType</code></strong> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <strong><code>weaveById</code>, and </strong><code>weaveByToString</code> this method uses the class type of the node(s) when matching. This allows you to match <a shape="rect" href="eip.html">EIP</a> pattern by its type.</p><p>The <strong><code>weaveByToType</code></strong> has the same methods as <strong><code>weaceById</code></strong> and <strong><code>weaveByToString</code></strong>.</p><p>For example to remove a transform from the following route:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader p
 anelHeader pdl" style="border-bottom-width: 1px;"><b>Route</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-from(&quot;direct:start&quot;)
-    .transform(simple(&quot;Hello ${body}&quot;))
-    .log(&quot;Got ${body}&quot;)
-    .to(&quot;mock:result&quot;);
-]]></script>
-</div></div>You can do:<div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Remove</b></div><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
-context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
-    @Override
-    public void configure() throws Exception {
-        // weave the type in the route and remove it
-        weaveByType(TransformDefinition.class).remove();
-    }
-});
-]]></script>
-</div></div><h3 id="AdviceWith-UsingSelectors">Using Selectors</h3><p><strong>Available os of Camel 2.8</strong></p><p>The following methods <strong><code>weaveById(pattern)</code></strong>, <strong><code>weaveByToString(pattern)</code></strong> and <strong><code>weaveByType(Class)</code></strong> each match N+ nodes. By using optional selectors you can narrow down the nodes being used. For example if <strong><code>weaveByType(Class)</code></strong> returns 2 nodes. Then you can use a selector to indicate it should only select the first node.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Selector</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectFirst</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the first matched node.</p></td></tr><tr><td colspan="1" rowspan="1" class=
 "confluenceTd"><p><code>selectLast</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the last matched node.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectIndex(index)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the N'th matched node. The index is zero-based.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectRange(from, to)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the matches node within the given range by index (both inclusive). The index is zero-based.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>maxDeep(to)</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.14.2/2.15:</strong> To limit the selection to at most N level deep in the Camel route tree. The first level is starting from number 1. So number 2 is the children of the 1st level nodes.</td></tr>
 </tbody></table></div><p>For example to remove the first <strong><code>.to</code></strong> node in route you can do as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+<div class="wiki-content maincontent"><h2 id="AdviceWith-AdviceWith">AdviceWith</h2><p><strong>Available as of Camel 2.1</strong></p><p>AdviceWith is used for testing Camel routes where you can <em>advice</em> an existing route before its being tested. What <strong><code>adviceWith</code></strong> allows is to changes some factors on the route before the test is being run. At the current time you can <em>advice</em> an existing route by adding <a shape="rect" href="intercept.html">Intercept</a>, <a shape="rect" href="exception-clause.html">Exception Clause</a> etc. which then will apply for the route being advice.</p><p>For example, in the route below we intercept sending a message to the <strong><code>mock:foo</code></strong> endpoint and detour the message.<plain-text-body>{snippet:id=e1|lang=java|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTest.java}</plain-text-body></p><parameter ac:name="title">Recommendation</parameter><rich-text-
 body><p>It is recommended to only advice a given route once (you can of course advice multiple routes). If you do it multiple times, then it may not work as expected, especially when any kind of error handling is involved.<br clear="none"> The Camel team plan for <strong>Camel 3.0</strong> to support this as internal refactorings in the routing engine is needed to support this properly.</p></rich-text-body><parameter ac:name="title">Recommendation</parameter><rich-text-body><p>It's recommended to only advice routes which are not started already. If you advice already started routes, then it may not work as expected.</p></rich-text-body><parameter ac:name="title">Telling Camel you are using adviceWith</parameter><rich-text-body><p>From <strong>Camel 2.9</strong>: it's recommended to override the <strong><code>isUseAdviceWith()</code></strong> method and return true to tell Camel you are using advice with in your unit tests. Then after you have done the <strong><code>adviceWith()</cod
 e></strong>, then you must start <strong><code>CamelContext</code></strong> manually. See further below for an example.</p></rich-text-body><h3 id="AdviceWith-UsingAdviceWithRouteBuilder">Using&#160;<code>AdviceWithRouteBuilder</code></h3><p><strong>Available as of Camel 2.7</strong></p><p>The <strong><code>AdviceWithRouteBuilder</code></strong> is a specialized <strong><code>RouteBuilder</code></strong> which has additional methods for advising routes. For example this allows you to manipulate the advised route, such as replacing a node with some other nodes.</p><p>The <strong><code>AdviceWithRouteBuilder</code></strong> offers the following extra methods:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpoints</code></p></td><td colspan="1" rowspan="1"
  class="confluenceTd"><p>Is used to easily mock all endpoints. See more details and examples at <a shape="rect" href="mock.html">Mock</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpoints(patterns)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock endpoints using a pattern. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. From Camel 2.10 onwards you can specify multiple patterns.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>mockEndpointsAndSkip(patterns)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to easily mock endpoints using a pattern, and <strong>skip</strong> sending to the original endpoint. See more details and examples at <a shape="rect" href="mock.html">Mock</a>. See below for pattern matching. You can specify multiple patterns.</p></td></tr><tr><td colspan="1" rowspan="1" clas
 s="confluenceTd"><p><code>weaveById(pattern)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to select node(s) matching by id's, and weave in the following nodes. See below for pattern matching and examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveByToString(pattern)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is used to select nodes(s) matching by their <strong><code>toString</code></strong> representation, and weave in the following nodes. See below for pattern matching and examples.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveByType(Class)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is used to select node(s) matching by their class type (the classes from the&#160;<strong><code>org.apache.camel.model</code></strong> package), and weave in the following nodes. See below for examples.</p></td></tr><tr><td col
 span="1" rowspan="1" class="confluenceTd"><p><code>weaveAddFirst</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the start of the route.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>weaveAddLast</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.8:</strong> Is a short hand to easily weave in the following nodes in the end of the route.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>replaceFromWith(uri)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.9:</strong> To replace the route input with a new endpoint URI.</p></td></tr></tbody></table></div><p>The <strong><code>pattern</code></strong> option is used for matching. It uses the same rules as the <a shape="rect" href="intercept.html">Intercept</a>, which is applied in the following order:</p><ul><li>match
  exact</li><li>match by wildcard</li><li>match by regular expression</li></ul><p>For example to match exact you can use&#160;<strong><code>weaveById("foo")</code></strong> which will match only the id in the route which has the value: <strong><code>foo</code></strong>. The wildcard is when the pattern ends with a&#160;<strong><code>*</code></strong> character, such as:&#160;<strong><code>weaveById("foo*")</code></strong> which will match any id's starting with <strong><code>foo</code></strong>, such as: <strong><code>foo</code>, <code>foobar</code></strong>,&#160;<strong><code>foobie</code></strong> and so forth. The regular expression is more advanced and allows you to match multiple ids, such as&#160;<strong><code>weaveById("(foo|bar)")</code></strong> which will match both&#160;<strong><code>foo</code></strong> and <strong><code>bar</code></strong>.</p><rich-text-body><p>If you try to match a <code>pattern</code> on an exact endpoint URI, then mind that URI options ordering may i
 nfluence, and hence its best to match by wildcard.</p><p>For example:</p><plain-text-body>mockEndpointsAndSkip("activemq:queue:foo?*")
+</plain-text-body><p>To match the&#160;<strong><code>foo</code></strong> queue and disregard any options.</p></rich-text-body><h3 id="AdviceWith-UsingweaveById">Using&#160;<code>weaveById</code></h3><p>The <strong><code>weaveById</code></strong> allows you to manipulate the route, for example by replacing a node with other nodes.</p><p>The following methods are available:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>remove</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Removes the selected node(s).</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>replace</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Replaces the selected node(s) with the following nodes.</p></td></tr><tr><td colspan="1" rows
 pan="1" class="confluenceTd"><p><code>before</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Before the selected node(s), the following nodes is added.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>after</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>After the selected node(s), the following nodes is added.</p></td></tr></tbody></table></div><p>For example given the following route:</p><parameter ac:name="language">java</parameter><parameter ac:name="title">Route</parameter><plain-text-body>from("direct:start")
+    .to("mock:foo")
+    .to("mock:bar").id("bar")
+    .to("mock:result");
+</plain-text-body><p>Then let's go over the four methods to see how you can use them in unit tests:<plain-text-body>{snippet:id=e1|lang=java|title=Replace|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTasksTest.java}</plain-text-body>In this example we replace the <strong><code>.to("mock:bar").id("bar")</code></strong> with the <strong><code>.multicast().to("mock:a").to("mock:b")</code></strong>.<br clear="none"> That means instead of sending the message to a <code><strong>mock:bar</strong></code> endpoint, we do a <a shape="rect" href="multicast.html">Multicast</a> to <code><strong>mock:a</strong></code> and <code><strong>mock:b</strong></code> endpoints instead.<plain-text-body>{snippet:id=e2|lang=java|title=Remove|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTasksTest.java}</plain-text-body>In the example above, we simply just remove the <strong><code>.to("mock:bar").id("bar")</code></strong>
 .<plain-text-body>{snippet:id=e3|lang=java|title=Before|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTasksTest.java}</plain-text-body>In the example above, we add the following nodes <strong><code>to("mock:a").transform(constant("Bye World"))</code> before</strong> the node with the id <strong><code>bar</code></strong>.<br clear="none"> That means the message being send to <strong><code>mock:bar</code></strong> would have been transformed to a constant message "<strong><code>Bye World</code></strong>".<plain-text-body>{snippet:id=e4|lang=java|title=After|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTasksTest.java}</plain-text-body>In the example above, we add the following nodes <strong><code>to("mock:a").transform(constant("Bye World"))</code> after</strong> the node with the id&#160;<code><strong>bar</strong></code>.</p><h3 id="AdviceWith-UsingweaveByToString">Using&#160;<code>weaveByToString
 </code></h3><p>The <strong><code>weaveByToString</code></strong> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <strong><code>weaveById</code></strong>, this method uses the <strong><code>toString</code></strong> representation of the node(s) when matching. This allows you to match nodes, which may not have assigned ids, or to match <a shape="rect" href="eip.html">EIP</a> pattern. You have to be a bit more careful when using this as the <strong><code>toString</code></strong> representation can be verbose and contain characters such as <strong>[ ] ( )-&gt;</strong> and so forth. That is why using the regular expression matching is the must usable.</p><p>The <strong><code>weaveByToString</code></strong> has the same methods as <strong><code>weaveById</code></strong>.</p><p>For example to replace any nodes which has <code>"<strong>foo</strong>"</code> you can do<plain-text-body>{snippet:id=e1|lang=java|title=Replace|url=camel/tr
 unk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTasksToStringPatternTest.java}</plain-text-body>Notice that we have to use <code>".<strong>foo.</strong>"</code> in the pattern to match that <code>"<strong>foo</strong>"</code> is present anywhere in the string.</p><h3 id="AdviceWith-UsingweaveByType">Using&#160;<code>weaveByType</code></h3><p><strong>Available as of Camel 2.8</strong></p><p>The <strong><code>weaveByToType</code></strong> also allows you to manipulate the route, for example by replacing a node with other nodes. As opposed to <strong><code>weaveById</code>, and </strong><code>weaveByToString</code> this method uses the class type of the node(s) when matching. This allows you to match <a shape="rect" href="eip.html">EIP</a> pattern by its type.</p><p>The <strong><code>weaveByToType</code></strong> has the same methods as <strong><code>weaceById</code></strong> and <strong><code>weaveByToString</code></strong>.</p><p>For example to remove a 
 transform from the following route:<plain-text-body>{snippet:id=e5|lang=java|title=Route|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTypeTest.java}</plain-text-body>You can do:<plain-text-body>{snippet:id=e2|lang=java|title=Remove|url=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithTypeTest.java}</plain-text-body></p><h3 id="AdviceWith-UsingSelectors">Using Selectors</h3><p><strong>Available os of Camel 2.8</strong></p><p>The following methods <strong><code>weaveById(pattern)</code></strong>, <strong><code>weaveByToString(pattern)</code></strong> and <strong><code>weaveByType(Class)</code></strong> each match N+ nodes. By using optional selectors you can narrow down the nodes being used. For example if <strong><code>weaveByType(Class)</code></strong> returns 2 nodes. Then you can use a selector to indicate it should only select the first node.</p><div class="table-wrap"><table class="confluenceTable"
 ><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Selector</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectFirst</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the first matched node.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectLast</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the last matched node.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectIndex(index)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the N'th matched node. The index is zero-based.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>selectRange(from, to)</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Will only select the matches node within the given range by index (both in
 clusive). The index is zero-based.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>maxDeep(to)</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.14.2/2.15:</strong> To limit the selection to at most N level deep in the Camel route tree. The first level is starting from number 1. So number 2 is the children of the 1st level nodes.</td></tr></tbody></table></div><p>For example to remove the first <strong><code>.to</code></strong> node in route you can do as follows:</p><parameter ac:name="language">java</parameter><plain-text-body>context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
         // only remove the first to node in the route
         weaveByType(ToDefinition.class).selectFirst().remove();
     }
 });
-]]></script>
-</div></div><h3 id="AdviceWith-UsingweaveAddFirst/weaveAddLast">Using&#160;<code>weaveAddFirst</code> /&#160;<code>weaveAddLast</code></h3><p><strong>Available as of Camel 2.8</strong></p><p>The <strong><code>weaveAddFirst</code></strong> and <strong><code>weaveAddLast</code></strong> is a shorthand to easily add nodes to the route. These methods can only <strong>add</strong> to an existing routes. If you want to manipulate the route, then there are plenty of methods as already shown on this page.</p><p>For example if you want to send a message to a <strong><code>mock:input</code></strong> endpoint you can do as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+</plain-text-body><h3 id="AdviceWith-UsingweaveAddFirst/weaveAddLast">Using&#160;<code>weaveAddFirst</code> /&#160;<code>weaveAddLast</code></h3><p><strong>Available as of Camel 2.8</strong></p><p>The <strong><code>weaveAddFirst</code></strong> and <strong><code>weaveAddLast</code></strong> is a shorthand to easily add nodes to the route. These methods can only <strong>add</strong> to an existing routes. If you want to manipulate the route, then there are plenty of methods as already shown on this page.</p><p>For example if you want to send a message to a <strong><code>mock:input</code></strong> endpoint you can do as follows:</p><parameter ac:name="language">java</parameter><plain-text-body>context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
         // send the incoming message to mock:input
-        weaveAddFirst().to(&quot;mock:input&quot;);
+        weaveAddFirst().to("mock:input");
     }
 });
-]]></script>
-</div></div><p>Likewise if you want to easily send a message to a <code>mock:output</code> endpoint you can do as follows:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+</plain-text-body><p>Likewise if you want to easily send a message to a <code>mock:output</code> endpoint you can do as follows:</p><parameter ac:name="language">java</parameter><plain-text-body>context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
         // send the outgoing message to mock:output
-        weaveAddLast().to(&quot;mock:output&quot;);
+        weaveAddLast().to("mock:output");
     }
 });
-]]></script>
-</div></div><p>You can of course combine those in the same advice with:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+</plain-text-body><p>You can of course combine those in the same advice with:</p><parameter ac:name="language">java</parameter><plain-text-body>context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
-        weaveAddFirst().to(&quot;mock:input&quot;);
-        weaveAddLast().to(&quot;mock:output&quot;);
+        weaveAddFirst().to("mock:input");
+        weaveAddLast().to("mock:output");
     }
 });
-]]></script>
-</div></div><h3 id="AdviceWith-ReplacefromWithAnotherEndpoint">Replace&#160;<code>from</code> With Another Endpoint</h3><p><strong>Available as of Camel 2.9</strong></p><p>You may have routes which consumes messages from endpoints which you want to substitute with another endpoint for easier unit testing. For example a <a shape="rect" href="jms.html">JMS</a> endpoint could be replaced with a <a shape="rect" href="seda.html">SEDA</a> or <a shape="rect" href="direct.html">Direct</a> for unit testing a route, as shown below where we replace the input of the route to a&#160;<strong><code>seda:foo</code></strong> endpoint:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
+</plain-text-body><h3 id="AdviceWith-ReplacefromWithAnotherEndpoint">Replace&#160;<code>from</code> With Another Endpoint</h3><p><strong>Available as of Camel 2.9</strong></p><p>You may have routes which consumes messages from endpoints which you want to substitute with another endpoint for easier unit testing. For example a <a shape="rect" href="jms.html">JMS</a> endpoint could be replaced with a <a shape="rect" href="seda.html">SEDA</a> or <a shape="rect" href="direct.html">Direct</a> for unit testing a route, as shown below where we replace the input of the route to a&#160;<strong><code>seda:foo</code></strong> endpoint:</p><parameter ac:name="language">java</parameter><plain-text-body>context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
     @Override
     public void configure() throws Exception {
-        replaceFromWith(&quot;seda:foo&quot;);
+        replaceFromWith("seda:foo");
     }
 });
-]]></script>
-</div></div><h3 id="AdviceWith-UsingMockEndpoints">Using Mock Endpoints</h3><p>While routing messages, you may want to easily know how the messages was routed. For example you can let Camel mock all endpoints, which mean that when a message is sent to any endpoint, its first send to a mock endpoint, and then afterwards to the original endpoint. Then from your unit tests, you can setup expectations on the mock endpoints.</p><p>See more details see: <em>Mocking existing endpoints using the camel-test component</em> at <a shape="rect" href="mock.html">Mock</a>.</p><h3 id="AdviceWith-UsingisUseAdviceWith()">Using&#160;<code>isUseAdviceWith()</code></h3><p><strong>Available as of Camel 2.9</strong><br clear="none"> It is recommended to override the method <strong><code>isUseAdviceWith</code></strong> and return <strong><code>true</code></strong> to instruct Camel that you are using <strong><code>adviceWith</code></strong> in the unit tests. Then in your unit test methods, after you have 
 done the <strong><code>adviceWith</code></strong> you <strong>must</strong> start <strong><code>CamelContext</code></strong> by invoke the <strong><code>start</code></strong> method on the <code>context</code> instance. In the following we have an example. The route is using <a shape="rect" href="activemq.html">ActiveMQ</a> to route messages. What we would like to do in a unit test is to test the route, but without having to set and use <a shape="rect" href="activemq.html">ActiveMQ</a>. We do not have <a shape="rect" href="activemq.html">ActiveMQ</a> on the classpath. So for that we need to advice the route and replace <a shape="rect" href="activemq.html">ActiveMQ</a> with for example a <a shape="rect" href="seda.html">SEDA</a> endpoint instead.</p><div class="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div></div>
+</plain-text-body><h3 id="AdviceWith-UsingMockEndpoints">Using Mock Endpoints</h3><p>While routing messages, you may want to easily know how the messages was routed. For example you can let Camel mock all endpoints, which mean that when a message is sent to any endpoint, its first send to a mock endpoint, and then afterwards to the original endpoint. Then from your unit tests, you can setup expectations on the mock endpoints.</p><p>See more details see: <em>Mocking existing endpoints using the camel-test component</em> at <a shape="rect" href="mock.html">Mock</a>.</p><h3 id="AdviceWith-UsingisUseAdviceWith()">Using&#160;<code>isUseAdviceWith()</code></h3><p><strong>Available as of Camel 2.9</strong><br clear="none"> It is recommended to override the method <strong><code>isUseAdviceWith</code></strong> and return <strong><code>true</code></strong> to instruct Camel that you are using <strong><code>adviceWith</code></strong> in the unit tests. Then in your unit test methods, after you
  have done the <strong><code>adviceWith</code></strong> you <strong>must</strong> start <strong><code>CamelContext</code></strong> by invoke the <strong><code>start</code></strong> method on the <code>context</code> instance. In the following we have an example. The route is using <a shape="rect" href="activemq.html">ActiveMQ</a> to route messages. What we would like to do in a unit test is to test the route, but without having to set and use <a shape="rect" href="activemq.html">ActiveMQ</a>. We do not have <a shape="rect" href="activemq.html">ActiveMQ</a> on the classpath. So for that we need to advice the route and replace <a shape="rect" href="activemq.html">ActiveMQ</a> with for example a <a shape="rect" href="seda.html">SEDA</a> endpoint instead.<plain-text-body>{snippet:id=e1|lang=java|title=isUseAdviceWith|url=camel/branches/camel-2.9.x/components/camel-test/src/test/java/org/apache/camel/test/IsUseAdviceWithJUnit4Test.java}</plain-text-body></p></div>
         </td>
         <td valign="top">
           <div class="navigation">