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 2016/03/10 17:22:23 UTC

svn commit: r982402 [2/3] - in /websites/production/camel/content: book-cookbook.html book-in-one-page.html cache/main.pageCache cdi-testing.html testing.html

Modified: websites/production/camel/content/book-in-one-page.html
==============================================================================
--- websites/production/camel/content/book-in-one-page.html (original)
+++ websites/production/camel/content/book-in-one-page.html Thu Mar 10 16:22:23 2016
@@ -2414,8 +2414,9 @@ public class IsMockEndpointsAndSkipJUnit
 ]]></script>
 </div></div><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">time units</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>In the example above we use <code>seconds</code> as the time unit, but Camel offers <code>milliseconds</code>, and <code>minutes</code> as well.</p></div></div><p></p><h3 id="BookInOnePage-SeeAlso">See Also</h3>
 <ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul><ul><li><a shape="rect" href="spring-testing.html">Spring Testing</a></li><li><a shape="rect" href="testing.html">Testing</a></li></ul>
-<h2 id="BookInOnePage-Testing">Testing</h2><p>Testing is a crucial activity in any piece of software development or integration. Typically Camel Riders use various different <a shape="rect" href="components.html">technologies</a> wired together in a variety of <a shape="rect" href="enterprise-integration-patterns.html">patterns</a> with different <a shape="rect" href="languages.html">expression languages</a> together with different forms of <a shape="rect" href="bean-integration.html">Bean Integration</a> and <a shape="rect" href="dependency-injection.html">Dependency Injection</a> so its very easy for things to go wrong! <img class="emoticon emoticon-smile" src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/emoticons/smile.png" data-emoticon-name="smile" alt="(smile)"> . Testing is the crucial weapon to ensure that things work as you would expect.</p><p>Camel is a Java library so you can easily wire up tests in whatever u
 nit testing framework you use (JUnit 3.x (deprecated), 4.x, or TestNG). However the Camel project has tried to make the testing of Camel as easy and powerful as possible so we have introduced the following features.</p><h3 id="BookInOnePage-Testingmechanisms">Testing mechanisms</h3><p>The following mechanisms are supported</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Component</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="camel-test.html">Camel Test</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-test</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is a standalone Java library letting you easily create Camel test cases using a single Java class for all your configuration and routing 
 without using <a shape="rect" href="spring.html">Spring</a> or <a shape="rect" href="guice.html">Guice</a> for <a shape="rect" href="dependency-injection.html">Dependency Injection</a>&#160;which does not require an in-depth knowledge of Spring + Spring Test or Guice. &#160;Supports JUnit 3.x (deprecated) and JUnit 4.x based tests.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" href="cdi-testing.html">CDI Testing</a></td><td colspan="1" rowspan="1" class="confluenceTd"><code>camel-test-cdi</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Provides a JUnit 4 runner that bootstraps a test environment using CDI so that you don't have to be familiar with any CDI testing frameworks and can concentrate on the testing logic of your Camel CDI applications. Testing frameworks like&#160;<a shape="rect" class="external-link" href="http://arquillian.org/" rel="nofollow">Arquillian</a>&#160;or&#160;<a shape="rect" class="external-link" href="https:
 //ops4j1.jira.com/wiki/display/PAXEXAM4" rel="nofollow">PAX Exam</a>, can be used for more advanced test cases, where you need to configure your system under test in a very fine-grained way or target specific CDI containers.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="spring-testing.html">Spring Testing</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-test-spring</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Supports JUnit 3.x (deprecated) or JUnit 4.x based tests that bootstrap a test environment using Spring without needing to be familiar with Spring Test. The plain JUnit 3.x/4.x based tests work very similar to the test support classes in <code>camel-test</code>. &#160;Also supports Spring Test based tests that use the declarative style of test configuration and injection common in Spring Test. &#160;The Spring Test based tests provide feature parity with the plain JUnit 3.x/4.x based t
 esting approach. &#160;Notice <code>camel-test-spring</code> is a new component in <strong>Camel 2.10</strong> onwards. For older Camel release use <code>camel-test</code> which has built-in <a shape="rect" href="spring-testing.html">Spring Testing</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="blueprint-testing.html">Blueprint Testing</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-test-blueprint</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Provides the ability to do unit testing on blueprint configurations</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="guice.html">Guice</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-guice</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Uses <a shape="rect" href="guice.html">Guice</a> to dependency inject your test classes</p></td><
 /tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Camel TestNG</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-testng</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Supports plain TestNG based tests&#160;with or without&#160;<a shape="rect" href="spring.html">Spring</a>&#160;or&#160;<a shape="rect" href="guice.html">Guice</a>&#160;for&#160;<a shape="rect" href="dependency-injection.html">Dependency Injection</a>&#160;which does not require an in-depth knowledge of Spring + Spring Test or Guice. &#160;Also from <strong>Camel 2.10</strong> onwards, this component supports Spring Test&#160;based tests that use the declarative style of test configuration and injection common in Spring Test and described in more detail under <a shape="rect" href="spring-testing.html">Spring Testing</a>.</p></td></tr></tbody></table></div><p>In all approaches the test classes look pretty much the same in that they all reuse the <a shape="rect" href="be
 an-integration.html">Camel binding and injection annotations</a>.</p><h4 id="BookInOnePage-CamelTestExample">Camel Test Example</h4><p>Here is the <a shape="rect" href="camel-test.html">Camel Test</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java">example</a>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<h2 id="BookInOnePage-Testing">Testing</h2><p>Testing is a crucial activity in any piece of software development or integration. Typically Camel Riders use various different <a shape="rect" href="components.html">technologies</a> wired together in a variety of <a shape="rect" href="enterprise-integration-patterns.html">patterns</a> with different <a shape="rect" href="languages.html">expression languages</a> together with different forms of <a shape="rect" href="bean-integration.html">Bean Integration</a> and <a shape="rect" href="dependency-injection.html">Dependency Injection</a> so its very easy for things to go wrong! <img class="emoticon emoticon-smile" src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/emoticons/smile.png" data-emoticon-name="smile" alt="(smile)"> . Testing is the crucial weapon to ensure that things work as you would expect.</p><p>Camel is a Java library so you can easily wire up tests in whatever u
 nit testing framework you use (JUnit 3.x (deprecated), 4.x, or TestNG). However the Camel project has tried to make the testing of Camel as easy and powerful as possible so we have introduced the following features.</p><h3 id="BookInOnePage-Testingmechanisms">Testing mechanisms</h3><p>The following mechanisms are supported:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Component</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="camel-test.html">Camel Test</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-test</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Is a standalone Java library letting you easily create Camel test cases using a single Java class for all your configuration and routing
  without using <a shape="rect" href="spring.html">Spring</a> or <a shape="rect" href="guice.html">Guice</a> for <a shape="rect" href="dependency-injection.html">Dependency Injection</a>&#160;which does not require an in-depth knowledge of Spring + Spring Test or Guice. &#160;Supports JUnit 3.x (deprecated) and JUnit 4.x based tests.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><a shape="rect" href="cdi-testing.html">CDI Testing</a></td><td colspan="1" rowspan="1" class="confluenceTd"><code><span>camel-test-cdi</span></code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Provides a JUnit 4 runner that bootstraps a test environment using CDI so that you don't have to be familiar with any CDI testing frameworks and can concentrate on the testing logic of your Camel CDI applications. Testing frameworks like&#160;<a shape="rect" class="external-link" href="http://arquillian.org/" rel="nofollow">Arquillian</a>&#160;or&#160;<a shape="rect" class="external-link
 " href="https://ops4j1.jira.com/wiki/display/PAXEXAM4" rel="nofollow">PAX Exam</a>, can be used for more advanced test cases, where you need to configure your system under test in a very fine-grained way or target specific CDI containers.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="spring-testing.html">Spring Testing</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-test-spring</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Supports JUnit 3.x (deprecated) or JUnit 4.x based tests that bootstrap a test environment using Spring without needing to be familiar with Spring Test. The plain JUnit 3.x/4.x based tests work very similar to the test support classes in <code>camel-test</code>. Also supports Spring Test based tests that use the declarative style of test configuration and injection common in Spring Test. The Spring Test based tests provide feature parity with the plain JUnit 3.x/4.x based
  testing approach. &#160;Notice <code>camel-test-spring</code> is a new component in <strong>Camel 2.10</strong> onwards. For older Camel release use <code>camel-test</code> which has built-in <a shape="rect" href="spring-testing.html">Spring Testing</a>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="blueprint-testing.html">Blueprint Testing</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-test-blueprint</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Provides the ability to do unit testing on blueprint configurations</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="guice.html">Guice</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-guice</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Uses <a shape="rect" href="guice.html">Guice</a> to dependency inject your test classes</p></td
 ></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Camel TestNG</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>camel-testng</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Supports plain TestNG based tests&#160;with or without&#160;<a shape="rect" href="spring.html">Spring</a>&#160;or&#160;<a shape="rect" href="guice.html">Guice</a>&#160;for&#160;<a shape="rect" href="dependency-injection.html">Dependency Injection</a>&#160;which does not require an in-depth knowledge of Spring + Spring Test or Guice. &#160;Also from <strong>Camel 2.10</strong> onwards, this component supports Spring Test&#160;based tests that use the declarative style of test configuration and injection common in Spring Test and described in more detail under <a shape="rect" href="spring-testing.html">Spring Testing</a>.</p></td></tr></tbody></table></div><p>In all approaches the test classes look pretty much the same in that they all reuse the <a shape="rect" href="
 bean-integration.html">Camel binding and injection annotations</a>.</p><h4 id="BookInOnePage-CamelTestExample">Camel Test Example</h4><p>Here is the <a shape="rect" href="camel-test.html">Camel Test</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java">example</a>:</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[
+// tag::example[]
 public class FilterTest extends CamelTestSupport {
 
     @EndpointInject(uri = &quot;mock:result&quot;)
@@ -2458,9 +2459,11 @@ public class FilterTest extends CamelTes
         };
     }
 }
+// end::example[]
 ]]></script>
-</div></div>Notice how it derives from the Camel helper class <strong>CamelTestSupport</strong> but has no Spring or Guice dependency injection configuration but instead overrides the <strong>createRouteBuilder()</strong> method.<h4 id="BookInOnePage-SpringTestwithXMLConfigExample">Spring Test with XML Config Example</h4><p>Here is the <a shape="rect" href="spring-testing.html">Spring Testing</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/patterns/FilterTest.java">example using XML Config</a>.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Notice how it derives from the Camel helper class <code>CamelTestSupport</code> but has no Spring or Guice dependency injection configuration but instead overrides the <code>createRouteBuilder()</code> method.<h4 id="BookInOnePage-SpringTestwithXMLConfigExample">Spring Test with XML Config Example</h4><p>Here is the <a shape="rect" href="spring-testing.html">Spring Testing</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/patterns/FilterTest.java">example using XML Config</a>:</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[
+// tag::example[]
 @ContextConfiguration
 public class FilterTest extends SpringRunWithTestSupport {
 
@@ -2492,9 +2495,11 @@ public class FilterTest extends SpringRu
         resultEndpoint.assertIsSatisfied();
     }
 }
+// end::example[]
 ]]></script>
-</div></div>Notice that we use <strong>@DirtiesContext</strong> on the test methods to force <a shape="rect" href="spring-testing.html">Spring Testing</a> to automatically reload the <a shape="rect" href="camelcontext.html">CamelContext</a> after each test method - this ensures that the tests don't clash with each other (e.g. one test method sending to an endpoint that is then reused in another test method).<p>Also notice the use of <strong>@ContextConfiguration</strong> to indicate that by default we should look for the <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/patterns/FilterTest-context.xml">FilterTest-context.xml on the classpath</a> to configure the test case which looks like this</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Notice that we use <code>@DirtiesContext</code> on the test methods to force <a shape="rect" href="spring-testing.html">Spring Testing</a> to automatically reload the <code><a shape="rect" href="camelcontext.html">CamelContext</a></code> after each test method - this ensures that the tests don't clash with each other (e.g. one test method sending to an endpoint that is then reused in another test method).<p>Also notice the use of <code>@ContextConfiguration</code> to indicate that by default we should look for the <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/patterns/FilterTest-context.xml"><code>FilterTest-context.xml</code> on the classpath</a> to configure the test case which looks like this:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+&lt;!-- tag::example[] --&gt;
 &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
        xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
@@ -2514,10 +2519,11 @@ public class FilterTest extends SpringRu
   &lt;/camelContext&gt;
 
 &lt;/beans&gt;
+&lt;!-- end::example[] --&gt;
 ]]></script>
 </div></div><h4 id="BookInOnePage-SpringTestwithJavaConfigExample">Spring Test with Java Config Example</h4><p>Here is the <a shape="rect" href="spring-testing.html">Spring Testing</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">example using Java Config</a>.</p><p>For more information see <a shape="rect" href="spring-java-config.html">Spring Java Config</a>.</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[
-
+// tag::example[]
 @RunWith(CamelSpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {FilterTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
 public class FilterTest extends AbstractJUnit4SpringContextTests {
@@ -2562,9 +2568,11 @@ public class FilterTest extends Abstract
         }
     }
 }
+// end::example[]
 ]]></script>
-</div></div>This is similar to the XML Config example above except that there is no XML file and instead the nested <strong>ContextConfig</strong> class does all of the configuration; so your entire test case is contained in a single Java class. We currently have to reference by class name this class in the <strong>@ContextConfiguration</strong> which is a bit ugly. Please vote for <a shape="rect" class="external-link" href="http://jira.springframework.org/browse/SJC-238" rel="nofollow">SJC-238</a> to address this and make Spring Test work more cleanly with Spring JavaConfig.<p>Its totally optional but for the ContextConfig implementation we derive from <strong>SingleRouteCamelConfiguration</strong> which is a helper Spring Java Config class which will configure the CamelContext for us and then register the RouteBuilder we create.</p><p>Since <strong>Camel 2.11.0</strong> you can use the CamelSpringJUnit4ClassRunner with CamelSpringDelegatingTestContextLoader like <a shape="rect" cl
 ass="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java">example using Java Config with CamelSpringJUnit4ClassRunner</a>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>This is similar to the XML Config example above except that there is no XML file and instead the nested <code>ContextConfig</code> class does all of the configuration; so your entire test case is contained in a single Java class. We currently have to reference by class name this class in the <code>@ContextConfiguration</code> which is a bit ugly. Please vote for <a shape="rect" class="external-link" href="http://jira.springframework.org/browse/SJC-238" rel="nofollow">SJC-238</a> to address this and make Spring Test work more cleanly with Spring JavaConfig.<p>Its totally optional but for the ContextConfig implementation we derive from <code>SingleRouteCamelConfiguration</code> which is a helper Spring Java Config class which will configure the <code>CamelContext</code> for us and then register the <code>RouteBuilder</code> we create.</p><p>Since <strong>Camel 2.11.0</strong> you can use the <code>CamelSpringJUnit4ClassRunner</code> with <code>CamelSpringDelegatingTestCont
 extLoader</code> like <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/test/CamelSpringDelegatingTestContextLoaderTest.java">example using Java Config with <code>CamelSpringJUnit4ClassRunner</code></a>:</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[
+// tag::example[]
 @RunWith(CamelSpringJUnit4ClassRunner.class)
 @ContextConfiguration(
         classes = {CamelSpringDelegatingTestContextLoaderTest.TestConfig.class},
@@ -2611,9 +2619,11 @@ public class CamelSpringDelegatingTestCo
         errorEndpoint.assertIsSatisfied();
     }
 }
+// end::example[]
 ]]></script>
 </div></div><h4 id="BookInOnePage-SpringTestwithXMLConfigandDeclarativeConfigurationExample">Spring Test with XML Config and Declarative Configuration Example</h4><p>Here is a Camel test support enhanced&#160;<a shape="rect" href="spring-testing.html">Spring Testing</a>&#160;<a shape="rect" class="external-link" href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java">example using XML Config and pure Spring Test based configuration of the Camel Context</a>:</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[
+// tag::example[]
 @RunWith(CamelSpringJUnit4ClassRunner.class)
 // must tell Spring to bootstrap with Camel
 @BootstrapWith(CamelTestContextBootstrapper.class)
@@ -2698,9 +2708,11 @@ public class CamelSpringJUnit4ClassRunne
         assertTrue(camelContext2.isLazyLoadTypeConverters());
     }
 }
+// end::example[]
 ]]></script>
-</div></div>Notice how a custom test runner is used with the&#160;<strong>@RunWith</strong>&#160;annotation to support the features of&#160;<strong>CamelTestSupport</strong>&#160;through annotations on the test class. &#160;See&#160;<a shape="rect" href="spring-testing.html">Spring Testing</a>&#160;for a list of annotations you can use in your tests.<h4 id="BookInOnePage-BlueprintTest">Blueprint Test</h4><p>Here is the <a shape="rect" href="blueprint-testing.html">Blueprint Testing</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java">example using XML Config</a>:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Notice how a custom test runner is used with the&#160;<code>@RunWith</code>&#160;annotation to support the features of&#160;<code>CamelTestSupport</code>&#160;through annotations on the test class. See&#160;<a shape="rect" href="spring-testing.html">Spring Testing</a>&#160;for a list of annotations you can use in your tests.<h4 id="BookInOnePage-BlueprintTest">Blueprint Test</h4><p>Here is the <a shape="rect" href="blueprint-testing.html">Blueprint Testing</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/DebugBlueprintTest.java">example using XML Config</a>:</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[
+// tag::example[]
 // to use camel-test-blueprint, then extend the CamelBlueprintTestSupport class,
 // and add your unit tests methods as shown below.
 public class DebugBlueprintTest extends CamelBlueprintTestSupport {
@@ -2713,7 +2725,7 @@ public class DebugBlueprintTest extends
     protected String getBlueprintDescriptor() {
         return &quot;org/apache/camel/test/blueprint/camelContext.xml&quot;;
     }
-   
+
     // here we have regular JUnit @Test method
     @Test
     public void testRoute() throws Exception {
@@ -2750,9 +2762,11 @@ public class DebugBlueprintTest extends
         debugAfterMethodCalled = true;
     }
 }
+// end::example[]
 ]]></script>
-</div></div>Also notice the use of <code><strong>getBlueprintDescriptors</strong></code> to indicate that by default we should look for the <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/camelContext.xml">camelContext.xml in the package</a> to configure the test case which looks like this:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div>Also notice the use of <code>getBlueprintDescriptors</code> to indicate that by default we should look for the <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/camelContext.xml"><code>camelContext.xml</code> in the package</a> to configure the test case which looks like this:<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+&lt;!-- tag::example[] --&gt;
 &lt;blueprint xmlns=&quot;http://www.osgi.org/xmlns/blueprint/v1.0.0&quot;
            xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
            xsi:schemaLocation=&quot;
@@ -2771,6 +2785,7 @@ public class DebugBlueprintTest extends
   &lt;/camelContext&gt;
 
 &lt;/blueprint&gt;
+&lt;!-- end::example[] --&gt;
 ]]></script>
 </div></div><h3 id="BookInOnePage-Testingendpoints">Testing endpoints</h3><p>Camel provides a number of endpoints which can make testing easier.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="dataset.html">DataSet</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>For load &amp; soak testing this endpoint provides a way to create huge numbers of messages for sending to <a shape="rect" href="components.html">Components</a> and asserting that they are consumed correctly</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="mock.html">Mock</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>For testing routes and mediation rules using mocks and allowing assertions to be added to an endpo
 int</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="test.html">Test</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Creates a <a shape="rect" href="mock.html">Mock</a> endpoint which expects to receive all the message bodies that could be polled from the given underlying endpoint</p></td></tr></tbody></table></div><p>The main endpoint is the <a shape="rect" href="mock.html">Mock</a> endpoint which allows expectations to be added to different endpoints; you can then run your tests and assert that your expectations are met at the end.</p><h3 id="BookInOnePage-Stubbingoutphysicaltransporttechnologies">Stubbing out physical transport technologies</h3><p>If you wish to test out a route but want to avoid actually using a real physical transport (for example to unit test a transformation route rather than performing a full integration test) then the following endpoints can be useful.</p><div class="table-wrap"><table class="conflue
 nceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="direct.html">Direct</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Direct invocation of the consumer from the producer so that single threaded (non-SEDA) in VM invocation is performed which can be useful to mock out physical transports</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="seda.html">SEDA</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Delivers messages asynchonously to consumers via a <a shape="rect" class="external-link" href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html" rel="nofollow">java.util.concurrent.BlockingQueue</a> which is good for testing asynchronous transports</p></td></tr><tr><td colspan="1" rowspan="1" class="
 confluenceTd"><p><a shape="rect" href="stub.html">Stub</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Works like <a shape="rect" href="seda.html">SEDA</a> but does not validate the endpoint uri, which makes stubbing much easier.</p></td></tr></tbody></table></div><h3 id="BookInOnePage-Testingexistingroutes">Testing existing routes</h3><p>Camel provides some features to aid during testing of existing routes where you cannot or will not use <a shape="rect" href="mock.html">Mock</a> etc. For example you may have a production ready route which you want to test with some 3rd party API which sends messages into this route.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="notifybuilder.html">NotifyBuilder</a></p></td><td colspan="1" rows
 pan="1" class="confluenceTd"><p>Allows you to be notified when a certain condition has occurred. For example when the route has completed 5 messages. You can build complex expressions to match your criteria when to be notified.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="advicewith.html">AdviceWith</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Allows you to <strong>advice</strong> or <strong>enhance</strong> an existing route using a <a shape="rect" href="routebuilder.html">RouteBuilder</a> style. For example you can add interceptors to intercept sending outgoing messages to assert those messages are as expected.</p></td></tr></tbody></table></div>
 <h2 id="BookInOnePage-CamelTest">Camel Test</h2><p>As a simple alternative to using <a shape="rect" href="cdi-testing.html">CDI Testing</a>,&#160;<a shape="rect" href="spring-testing.html">Spring Testing</a> or <a shape="rect" href="guice.html">Guice</a> the <strong>camel-test</strong> module was introduced so you can perform powerful <a shape="rect" href="testing.html">Testing</a> of your <a shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a> easily.</p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The <code>camel-test</code> JAR is using JUnit. There is an alternative <code>camel-testng</code> JAR (Camel 2.8 onwards) using the <a shape="rect" class="external-link" href="http://testng.org/doc/index.html" rel="nofollow">TestNG</a> test framework.</p></div></div>
 <h3 id="BookInOnePage-Addingtoyourpom.xml">Adding to your pom.xml</h3><p>To get started using Camel Test you will need to add an entry to your pom.xml</p><h4 id="BookInOnePage-JUnit">JUnit</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
@@ -2803,6 +2818,7 @@ public class DebugBlueprintTest extends
 ]]></script>
 </div></div><h3 id="BookInOnePage-Writingyourtest">Writing your test</h3><p>You firstly need to derive from the class <strong>CamelTestSupport</strong>&#160;(org.apache.camel.test.CamelTestSupport, org.apache.camel.test.junit4.CamelTestSupport, or org.apache.camel.testng.CamelTestSupport for JUnit 3.x, JUnit 4.x, and TestNG, respectively)&#160;and typically you will need to override the <strong>createRouteBuilder()</strong> or&#160;<strong>createRouteBuilders()</strong>&#160;method to create routes to be tested.</p><p>Here is an <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/java/org/apache/camel/test/patterns/FilterTest.java">example</a>.</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[
+// tag::example[]
 public class FilterTest extends CamelTestSupport {
 
     @EndpointInject(uri = &quot;mock:result&quot;)
@@ -2845,6 +2861,7 @@ public class FilterTest extends CamelTes
         };
     }
 }
+// end::example[]
 ]]></script>
 </div></div>Notice how you can use the various <a shape="rect" href="bean-integration.html">Camel binding and injection annotations</a> to inject individual <a shape="rect" href="endpoint.html">Endpoint</a> objects - particularly the <a shape="rect" href="mock.html">Mock endpoints</a> which are very useful for <a shape="rect" href="testing.html">Testing</a>. Also you can inject <a shape="rect" href="pojo-producing.html">producer objects such as ProducerTemplate or some application code interface</a> for sending messages or invoking services.<h4 id="BookInOnePage-FeaturesProvidedbyCamelTestSupport">Features Provided by CamelTestSupport</h4><p>The various <strong>CamelTestSupport</strong> classes provide a standard set of behaviors relating to the CamelContext used to host the route(s) under test. &#160;The classes provide a number of methods that allow a test to alter the configuration of the CamelContext used. &#160;The following table describes the available customization methods a
 nd the default behavior of tests that are built from a&#160;<strong>CamelTestSupport</strong> class.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Method Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Behavior</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean isUseRouteBuilder()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the route builders from returned from&#160;<strong>createRouteBuilder()</strong> or <strong>createRouteBuilders()</strong> should be added to the CamelContext used in the test should be started.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns true. &#160;<strong>createRouteBuilder()</strong>&#160;or&#160;<strong>createRouteBuilders()</strong> are invoked and the CamelContext is started automatically.</p></td></tr><tr><td colspan="
 1" rowspan="1" class="confluenceTd"><p>boolean isUseAdviceWith()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the CamelContext use in the test should be automatically started before test methods are invoked. <br clear="none" class="atl-forced-newline"> Override when using <a shape="rect" href="advicewith.html">advice with</a>&#160;and return true. &#160;This helps in knowing the adviceWith is to be used, and the&#160;CamelContext&#160;will not be started before&#160;the advice with takes place. This delay helps by ensuring the advice with has been property setup before the&#160;CamelContext&#160;is started.</p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Its important to start the CamelContext manually from the unit test after you are done doing all the advice with.</p></div></div></
 td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns false. &#160;the CamelContext is started automatically before test methods are invoked.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean isCreateCamelContextPerClass()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>See&#160;<a shape="rect" href="#BookInOnePage-SetupCamelContextonceperclass,orpereverytestmethod">Setup CamelContext once per class, or per every test method</a>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The CamelContext and routes are recreated for each test method.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>String isMockEndpoints()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Triggers the auto-mocking of endpoints whose URIs match the provided filter. &#160;The default&#160;filter is null which disables this feature. &#160;Return "*" &#160;to match all endpoints. &#160;See&#160;org.apache.camel.impl.Intercept
 SendToMockEndpointStrategy&#160;for&#160;more details on the registration of the mock endpoints.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disabled</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean isUseDebugger()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If this method returns true, the&#160;<strong>debugBefore(Exchange exchange, Processor processor, ProcessorDefinition&lt;?&gt; definition,&#160;String id, String label)</strong>&#160;and&#160;<br clear="none" class="atl-forced-newline"> <strong>debugAfter(Exchange exchange, Processor processor, ProcessorDefinition&lt;?&gt; definition,&#160;String id, String label, long timeTaken)</strong>&#160;methods are invoked for each processor in the registered routes.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disabled. &#160;The methods are not invoked during the test.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>int getShutdownTimeout()</
 p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns the number of seconds that Camel should wait for graceful shutdown. &#160;Useful for decreasing test times when a message is still in flight at the end of the test.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns 10 seconds.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean useJmx()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If JMX should be disabled on the CamelContext used in the test.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>JMX is disabled.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>JndiRegistry createRegistry()</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Provides a hook for adding objects into the registry. &#160;Override this method to bind objects to the registry before test methods are invoked.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>An empty registry is initialized.
 </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>useOverridePropertiesWithPropertiesComponent</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Allows to add/override properties when <a shape="rect" href="using-propertyplaceholder.html">Using PropertyPlaceholder</a> in Camel.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>null</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>ignoreMissingLocationWithPropertiesComponent</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Allows to control if Camel should ignore missing locations for properties.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>null</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">boolean isDumpRouteCoverage</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong> If enabled, then Camel will dump all route coverage statistics into XML file
 s in the target/camel-route-coverage directory. These XML files contains information about "route coverage" of all the routes that was used during the unit test. This allows tooling to inspect these XML files and generate nice route coverage reports.</td><td colspan="1" rowspan="1" class="confluenceTd">Disabled.</td></tr></tbody></table></div><h3 id="BookInOnePage-JNDI">JNDI</h3><p>Camel uses a <a shape="rect" href="registry.html">Registry</a> to allow you to configure <a shape="rect" href="component.html">Component</a> or <a shape="rect" href="endpoint.html">Endpoint</a> instances or <a shape="rect" href="bean-integration.html">Beans used in your routes</a>. If you are not using <a shape="rect" href="spring.html">Spring</a> or <a shape="rect" class="unresolved" href="#">OSGi</a> then <a shape="rect" href="jndi.html">JNDI</a> is used as the default registry implementation.</p><p>So you will also need to create a <strong>jndi.properties</strong> file in your <strong>src/test/resource
 s</strong> directory so that there is a default registry available to initialise the <a shape="rect" href="camelcontext.html">CamelContext</a>.</p><p>Here is <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/jndi.properties">an example jndi.properties file</a></p><h3 id="BookInOnePage-Dynamicallyassigningports">Dynamically assigning ports</h3><p><strong>Available as of Camel 2.7</strong></p><p>Tests that use port numbers will fail if that port is already on use. <code>AvailablePortFinder</code> provides methods for finding unused port numbers at runtime.</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[// Get the next available port number starting from the default starting port of 1024
@@ -2906,6 +2923,7 @@ public class FilterCreateCamelContextPer
 ]]></script>
 </div></div><p>You are responsible for the instantiation of the Spring context in the method implementation. &#160;All of the features available in the non-Spring aware counterparts from <a shape="rect" href="camel-test.html">Camel Test</a> are available in your test.</p><h3 id="BookInOnePage-PlainSpringTest">Plain Spring Test</h3><p>In this approach, your test classes directly inherit from the Spring Test abstract test classes or use the JUnit 4.x test runner provided in Spring Test. &#160;This approach supports&#160;dependency&#160;injection into your test class and the full suite of Spring Test annotations but does not support the features provided by the CamelSpringTestSupport classes.</p><h4 id="BookInOnePage-PlainSpringTestusingJUnit3.xwithXMLConfigExample">Plain Spring Test using JUnit 3.x with XML Config Example</h4><p>Here is a simple unit test using JUnit 3.x support from Spring Test using&#160;<a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cam
 el/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/patterns/FilterTest.java">XML Config</a>.</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[
+// tag::example[]
 @ContextConfiguration
 public class FilterTest extends SpringRunWithTestSupport {
 
@@ -2937,9 +2955,11 @@ public class FilterTest extends SpringRu
         resultEndpoint.assertIsSatisfied();
     }
 }
+// end::example[]
 ]]></script>
 </div></div>Notice that we use&#160;<strong>@DirtiesContext</strong>&#160;on the test methods to force&#160;<a shape="rect" href="spring-testing.html">Spring Testing</a>&#160;to automatically reload the&#160;<a shape="rect" href="camelcontext.html">CamelContext</a>&#160;after each test method - this ensures that the tests don't clash with each other (e.g. one test method sending to an endpoint that is then reused in another test method).<p>Also notice the use of&#160;<strong>@ContextConfiguration</strong>&#160;to indicate that by default we should look for the&#160;<a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/patterns/FilterTest-context.xml">FilterTest-context.xml on the classpath</a>&#160;to configure the test case which looks like this</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[
+&lt;!-- tag::example[] --&gt;
 &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
        xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
        xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
@@ -2959,6 +2979,7 @@ public class FilterTest extends SpringRu
   &lt;/camelContext&gt;
 
 &lt;/beans&gt;
+&lt;!-- end::example[] --&gt;
 ]]></script>
 </div></div>This test will load a Spring XML configuration file calledFilterTest-context.xml&#160;from the classpath in the same package structure as the FilterTest class and initialize it along with any Camel routes we define inside it, then inject theCamelContextinstance into our test case.<p>For instance, like this maven folder layout:</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[src/test/java/org/apache/camel/spring/patterns/FilterTest.java
@@ -2966,7 +2987,7 @@ src/test/resources/org/apache/camel/spri
 ]]></script>
 </div></div><h4 id="BookInOnePage-PlainSpringTestusingJUnit4.xwithJavaConfigExample">Plain Spring Test using JUnit 4.x with Java Config Example</h4><p>You can completely avoid using an XML configuration file by using <a shape="rect" href="spring-java-config.html">Spring Java Config</a>. &#160;Here is a unit test using JUnit 4.x support from Spring Test using&#160;<a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">Java Config</a>.</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[
-
+// tag::example[]
 @RunWith(CamelSpringJUnit4ClassRunner.class)
 @ContextConfiguration(classes = {FilterTest.ContextConfig.class}, loader = CamelSpringDelegatingTestContextLoader.class)
 public class FilterTest extends AbstractJUnit4SpringContextTests {
@@ -3011,6 +3032,7 @@ public class FilterTest extends Abstract
         }
     }
 }
+// end::example[]
 ]]></script>
 </div></div>This is similar to the XML Config example above except that there is no XML file and instead the nested <strong>ContextConfig</strong> class does all of the configuration; so your entire test case is contained in a single Java class. We currently have to reference by class name this class in the <strong>@ContextConfiguration</strong> which is a bit ugly. Please vote for <a shape="rect" class="external-link" href="http://jira.springframework.org/browse/SJC-238" rel="nofollow">SJC-238</a> to address this and make Spring Test work more cleanly with Spring JavaConfig.<h4 id="BookInOnePage-PlainSpringTestusingJUnit4.0.xRunnerwithXMLConfig">Plain Spring Test using JUnit 4.0.x Runner with XML Config</h4><p>You can avoid extending Spring classes by using the SpringJUnit4ClassRunner provided by Spring Test. &#160;This custom JUnit runner means you are free to choose your own class hierarchy while retaining all the capabilities of Spring Test.</p><div class="confluence-information
 -macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This is for Spring 4.0.x. If you use Spring 4.1 or newer, then see the next section.</p></div></div><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[@RunWith(SpringJUnit4ClassRunner.class)
@@ -3670,11 +3692,11 @@ The tutorial has been designed in two pa
 While not actual tutorials you might find working through the source of the various <a shape="rect" href="examples.html">Examples</a> useful.</li></ul>
 
 <h2 id="BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</h2><p>&#160;</p><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Thanks</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This tutorial was kindly donated to Apache Camel by Martin Gilday.</p></div></div><h2 id="BookInOnePage-Preface">Preface</h2><p>This tutorial aims to guide the reader through the stages of creating a project which uses Camel to facilitate the routing of messages from a JMS queue to a <a shape="rect" class="external-link" href="http://www.springramework.org" rel="nofollow">Spring</a> service. The route works in a synchronous fashion returning a response to the client.</p><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1457612333109 {padding: 0px;}
-div.rbtoc1457612333109 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1457612333109 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1457626730240 {padding: 0px;}
+div.rbtoc1457626730240 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1457626730240 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1457612333109">
+/*]]>*/</style></p><div class="toc-macro rbtoc1457626730240">
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialonSpringRemotingwithJMS">Tutorial on Spring Remoting with JMS</a></li><li><a shape="rect" href="#BookInOnePage-Preface">Preface</a></li><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-About">About</a></li><li><a shape="rect" href="#BookInOnePage-CreatetheCamelProject">Create the Camel Project</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-UpdatethePOMwithDependencies">Update the POM with Dependencies</a></li></ul>
 </li><li><a shape="rect" href="#BookInOnePage-WritingtheServer">Writing the Server</a>
@@ -5789,11 +5811,11 @@ So we completed the last piece in the pi
 <p>This example has been removed from <strong>Camel 2.9</strong> onwards. Apache Axis 1.4 is a very old and unsupported framework. We encourage users to use <a shape="rect" href="cxf.html">CXF</a> instead of Axis.</p></div></div>
 
 <style type="text/css">/*<![CDATA[*/
-div.rbtoc1457612333576 {padding: 0px;}
-div.rbtoc1457612333576 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1457612333576 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1457626731790 {padding: 0px;}
+div.rbtoc1457626731790 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1457626731790 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style><div class="toc-macro rbtoc1457612333576">
+/*]]>*/</style><div class="toc-macro rbtoc1457626731790">
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-TutorialusingAxis1.4withApacheCamel">Tutorial using Axis 1.4 with Apache Camel</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Prerequisites">Prerequisites</a></li><li><a shape="rect" href="#BookInOnePage-Distribution">Distribution</a></li><li><a shape="rect" href="#BookInOnePage-Introduction">Introduction</a></li><li><a shape="rect" href="#BookInOnePage-SettinguptheprojecttorunAxis">Setting up the project to run Axis</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Maven2">Maven 2</a></li><li><a shape="rect" href="#BookInOnePage-wsdl">wsdl</a></li><li><a shape="rect" href="#BookInOnePage-ConfiguringAxis">Configuring Axis</a></li><li><a shape="rect" href="#BookInOnePage-RunningtheExample">Running the Example</a></li></ul>
@@ -17248,11 +17270,11 @@ template.send(&quot;direct:alias-verify&
 ]]></script>
 </div></div><p></p><h3 id="BookInOnePage-SeeAlso.28">See Also</h3>
 <ul><li><a shape="rect" href="configuring-camel.html">Configuring Camel</a></li><li><a shape="rect" href="component.html">Component</a></li><li><a shape="rect" href="endpoint.html">Endpoint</a></li><li><a shape="rect" href="getting-started.html">Getting Started</a></li></ul><ul><li><a shape="rect" href="crypto.html">Crypto</a> Crypto is also available as a <a shape="rect" href="data-format.html">Data Format</a></li></ul> <h2 id="BookInOnePage-CXFComponent">CXF Component</h2><div class="confluence-information-macro confluence-information-macro-note"><span class="aui-icon aui-icon-small aui-iconfont-warning confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using CXF as a consumer, the <a shape="rect" href="cxf-bean-component.html">CXF Bean Component</a> allows you to factor out how message payloads are received from their processing as a RESTful or SOAP web service. This has the potential of using a multitude of transports to consume web 
 services. The bean component's configuration is also simpler and provides the fastest method to implement web services using Camel and CXF.</p></div></div><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>When using CXF in streaming modes (see DataFormat option), then also read about <a shape="rect" href="stream-caching.html">Stream caching</a>.</p></div></div><p>The <strong>cxf:</strong> component provides integration with <a shape="rect" href="http://cxf.apache.org">Apache CXF</a> for connecting to JAX-WS services hosted in CXF.</p><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1457612339164 {padding: 0px;}
-div.rbtoc1457612339164 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1457612339164 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1457626793896 {padding: 0px;}
+div.rbtoc1457626793896 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1457626793896 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1457612339164">
+/*]]>*/</style></p><div class="toc-macro rbtoc1457626793896">
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-CXFComponent">CXF Component</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-URIformat">URI format</a></li><li><a shape="rect" href="#BookInOnePage-Options">Options</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#BookInOnePage-Thedescriptionsofthedataformats">The descriptions of the dataformats</a>

Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/camel/content/cdi-testing.html
==============================================================================
--- websites/production/camel/content/cdi-testing.html (original)
+++ websites/production/camel/content/cdi-testing.html Thu Mar 10 16:22:23 2016
@@ -116,7 +116,7 @@ public class CamelCdiTest {
         producer.sendBody(&quot;bar&quot;);
     }
 }]]></script>
-</div></div><p><span style="color: rgb(0,0,0);">Camel CDI test provides the&#160;</span><code style="color: rgb(0,0,0);">@Order</code><span style="color: rgb(0,0,0);"> annotation that you can use to execute the test methods in a particular sequence, e.g.:</span><span style="color: rgb(0,0,0);">&#160;</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p><span style="color: rgb(0,0,0);">Camel CDI test provides the&#160;</span><code style="color: rgb(0,0,0);">@Order</code><span style="color: rgb(0,0,0);"> annotation that you can use to execute the test methods in a particular sequence, e.g.:</span></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[@RunWith(CamelCdiRunner.class)
 public class CamelCdiTest {
  
@@ -130,7 +130,7 @@ public class CamelCdiTest {
     public void secondTestMethod() {
     }
 }]]></script>
-</div></div><p><span style="color: rgb(0,0,0);">One CDI container is bootstrapped for the entire execution of the test class.&#160;</span></p><p><span style="color: rgb(0,0,0);">Besides, the test class is deployed as a CDI bean, so that you can control how the runner instantiate the test class, either one test class instance for each test method (the default, depending on the built-in default&#160;<code>@Dependent</code>&#160;CDI scope), or one test class instance for the entire test class execution using the&#160;<code>@ApplicationScoped</code>&#160;scope, e.g.:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p><span style="color: rgb(0,0,0);">One CDI container is bootstrapped for the entire execution of the test class.</span></p><p><span style="color: rgb(0,0,0);">Besides, the test class is deployed as a CDI bean, so that you can control how the runner instantiate the test class, either one test class instance for each test method (the default, depending on the built-in default&#160;<code>@Dependent</code>&#160;CDI scope), or one test class instance for the entire test class execution using the&#160;<code>@ApplicationScoped</code>&#160;scope, e.g.:</span></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[@ApplicationScoped
 @RunWith(CamelCdiRunner.class)
 public class CamelCdiTest {
@@ -328,7 +328,7 @@ public class PaxCdiOsgiTest {
     }
 }
 ]]></script>
-</div></div><p>You can see the tests in<span style="color: rgb(0,0,0);">&#160;the&#160;</span><span style="color: rgb(0,0,0);"><code>camel-example-cdi-osgi</code>&#160;example for a complete working example of testing a Camel CDI application deployed in an OSGi container using PAX Exam.</span></p><h3 id="CDITesting-TestingPatterns">Testing Patterns</h3><p>You can see the tests in<span style="color: rgb(0,0,0);">&#160;the&#160;</span><span style="color: rgb(0,0,0);"><code>camel-example-cdi-test</code>&#160;example for a thorough overview of the following testing patterns for Camel CDI applications.</span></p><h4 id="CDITesting-Testroutes"><span style="color: rgb(0,0,0);">Test routes</span></h4><p><span style="color: rgb(0,0,0);">You may want to add some Camel routes to your Camel CDI applications for testing purpose. For example to route some exchanges to a <code>MockEndpoint</code> instance. You can do that by declaring a <code>RouteBuilder</code> bean within the test class as you w
 ould normally do in your application code, e.g.:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>You can see the tests in<span style="color: rgb(0,0,0);">&#160;the&#160;</span><span style="color: rgb(0,0,0);"><code>camel-example-cdi-osgi</code>&#160;example for a complete working example of testing a Camel CDI application deployed in an OSGi container using PAX Exam.</span></p><h3 id="CDITesting-TestingPatterns">Testing Patterns</h3><p>You can see the tests in<span style="color: rgb(0,0,0);">&#160;the&#160;</span><span style="color: rgb(0,0,0);"><code>camel-example-cdi-test</code>&#160;example for a thorough overview of the following testing patterns for Camel CDI applications.</span></p><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>While the patterns above are illustrated using the Camel CDI test module, they should equally work with Arquillian and PAX Exam unless otherwise stated 
 or illustrated with a specific example.</p></div></div><h4 id="CDITesting-Testroutes"><span style="color: rgb(0,0,0);">Test routes</span></h4><p><span style="color: rgb(0,0,0);">You may want to add some Camel routes to your Camel CDI applications for testing purpose. For example to route some exchanges to a <code>MockEndpoint</code> instance. You can do that by declaring a <code>RouteBuilder</code> bean within the test class as you would normally do in your application code, e.g.:</span></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[@RunWith(CamelCdiRunner.class)
 public class CamelCdiTest {
  
@@ -346,7 +346,14 @@ public class CamelCdiTest {
     @Uri(&quot;mock:out&quot;)
     MockEndpoint mock;
 }]]></script>
-</div></div><p><span style="color: rgb(0,0,0);">You can find more information in <a shape="rect" href="cdi.html#CDI-Auto-detectingCamelroutes">auto-detecting Camel routes</a>.</span></p><h4 id="CDITesting-Beanalternatives"><span style="color: rgb(0,0,0);">Bean alternatives</span></h4><p><span style="color: rgb(0,0,0);">You may want to replace a bean that is used in your Camel routes by another bean for testing purpose, for example to mock it or change the behaviour of the application bean.</span></p><p><span style="color: rgb(0,0,0);">Imagine you have the following route in your application:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p><span style="color: rgb(0,0,0);">You can find more information in <a shape="rect" href="cdi.html#CDI-Auto-detectingCamelroutes">auto-detecting Camel routes</a>.</span></p><p>In case you prefer declaring the <code>RouteBuilder</code> bean in a separate class,&#160;for example to share it more easily across multiple test classes, you can use&#160;the <code>@Beans</code> annotation to instruct Camel CDI test to deploy that class as a&#160;CDI bean, e.g.:</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[@RunWith(CamelCdiRunner.class)
+@Beans(classes = TestRoute.class)
+public class CamelCdiTest {
+
+    // ...
+}]]></script>
+</div></div><h4 id="CDITesting-Beanalternatives"><span style="color: rgb(0,0,0);">Bean alternatives</span></h4><p><span style="color: rgb(0,0,0);">You may want to replace a bean that is used in your Camel routes by another bean for testing purpose, for example to mock it or change the behaviour of the application bean.</span></p><p><span style="color: rgb(0,0,0);">Imagine you have the following route in your application:</span></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 class Application {
 
     @ContextName(&quot;camel-test-cdi&quot;)
@@ -422,7 +429,7 @@ public class CamelCdiTest {
 
     //...
 }]]></script>
-</div></div><h4 id="CDITesting-Camelcontextcustomisation"><span style="color: rgb(0,0,0);">Camel context customisation</span></h4><p><span style="color: rgb(0,0,0);">You may need to customise your Camel contexts for testing purpose, for example disabling JMX management to avoid TCP port allocation conflict. You can do that by declaring a custom Camel context bean in your test class, e.g.:</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h4 id="CDITesting-Camelcontextcustomization"><span style="color: rgb(0,0,0);">Camel context customization</span></h4><p><span style="color: rgb(0,0,0);">You may need to customize your Camel contexts for testing purpose, for example disabling JMX management to avoid TCP port allocation conflict. You can do that by declaring a custom Camel context bean in your test class, e.g.:</span></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[@RunWith(CamelCdiRunner.class)
 public class CamelCdiTest {
 Â