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/01/30 22:19:12 UTC

svn commit: r1005941 [3/4] - in /websites/production/camel/content: book-cookbook.html book-in-one-page.html cache/main.pageCache spring-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 Mon Jan 30 22:19:12 2017
@@ -2813,7 +2813,7 @@ 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="cdi.html">CDI</a>, <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>. 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 t
 he plain JUnit 3.x/4.x based testing approach. 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><strong>Deprecated</strong> 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><strong>Deprecated</strong> Supports plain TestNG based tests&#160;with or without <a shape="rect" href="cdi.html">CDI</a>,&#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 CDI, 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></t
 able></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">
+<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="cdi.html">CDI</a>, <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 <strong><code>camel-test</code></strong>.</p><p>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 provid
 e feature parity with the plain JUnit 3.x/4.x based testing approach.</p><p><strong>Note</strong>: <strong><code>camel-test-spring</code></strong> is a new component from <strong>Camel 2.10</strong>. For older Camel release use <strong><code>camel-test</code></strong> 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>
 <span style="color: rgb(255,0,0);"><strong>Deprecated</strong></span></p><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><span style="color: rgb(255,0,0);"><strong>Deprecated</strong></span></p><p>Supports plain TestNG based tests&#160;with or without <a shape="rect" href="cdi.html">CDI</a>,&#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 CDI, Spring + Spring Test or Guice. &#160;</p><p>From <strong>Camel 2.10</strong>: this component supports Spring Test&#160;based tests that use the declarative style of test configura
 tion 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 {
@@ -2860,7 +2860,7 @@ public class FilterTest extends CamelTes
 }
 // end::example[]
 ]]></script>
-</div></div>Notice how it derives from the Camel helper class <code>CamelTestSupport</code> but has no CDI, Spring or Guice dependency injection configuration but instead overrides the <code>createRouteBuilder()</code> method.<h4 id="BookInOnePage-CDITestexample">CDI Test example</h4><p>Here is the <a shape="rect" href="cdi-testing.html">CDI Testing</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test-cdi/src/test/java/org/apache/camel/test/cdi/FilterTest.java">example</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 <strong><code>CamelTestSupport</code></strong> but has no CDI, Spring or Guice dependency injection configuration but instead overrides the <strong><code>createRouteBuilder()</code></strong> method.<h4 id="BookInOnePage-CDITestExample">CDI Test Example</h4><p>Here is the <a shape="rect" href="cdi-testing.html">CDI Testing</a> <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test-cdi/src/test/java/org/apache/camel/test/cdi/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[]
 @RunWith(CamelCdiRunner.class)
@@ -2907,7 +2907,7 @@ public class FilterTest {
 }
 // end::example[]
 ]]></script>
-</div></div>You can find more testing patterns illustrated in the <code>camel-example-cdi-test</code> example&#160;and the test classes that come with it.<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>You can find more testing patterns illustrated in the <strong><code>camel-example-cdi-test</code></strong> example&#160;and the test classes that come with it.<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
@@ -2943,7 +2943,7 @@ public class FilterTest extends SpringRu
 }
 // end::example[]
 ]]></script>
-</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">
+</div></div>Notice that we use <strong><code>@DirtiesContext</code></strong> 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 note the use of <strong><code>@ContextConfiguration</code></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"><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;
@@ -3016,7 +3016,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 <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">
+</div></div>This is similar to the XML Config example above except that there is no XML file and instead the nested <strong><code>ContextConfig</code></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><code>@ContextConfiguration</code></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&#160;<strong><code>ContextConfig</code></strong> implementation we derive from <strong><code>SingleRouteCamelConfiguration</code></strong> which is a helper Spring Java Config class which will configure the <strong><code>CamelContext</code></strong> for us and then register the <strong><code>RouteBuilder</code></strong> we create.</p><p>Since <strong>
 Camel 2.11.0</strong> you can use the <strong><code>CamelSpringJUnit4ClassRunner</code></strong> with <strong><code>CamelSpringDelegatingTestContextLoader</code></strong> 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)
@@ -3067,7 +3067,7 @@ public class CamelSpringDelegatingTestCo
 }
 // 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="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </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">
+</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="error"><span class="error">Error formatting macro: snippet: java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>Notice how a custom test runner is used with the&#160;<strong><code>@RunWith</code></strong>&#160;annotation to support the features of&#160;<strong><code>CamelTestSupport</code></strong>&#160;through annotations on the test class. See&#160;<a shape="rect" href="spring-testing.h
 tml">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,
@@ -3121,7 +3121,7 @@ public class DebugBlueprintTest extends
 }
 // end::example[]
 ]]></script>
-</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">
+</div></div>Also notice the use of <strong><code>getBlueprintDescriptors</code></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-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;
@@ -3144,7 +3144,7 @@ public class DebugBlueprintTest extends
 &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>
+</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 asynchronously 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" row
 span="1" class="confluenceTd"><p>Allows you to be notified when a certain condition has occurred. For example when the route has completed five 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">
 <script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
@@ -3275,10 +3275,10 @@ public class FilterCreateCamelContextPer
 <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory
 ]]></script>
 </div></div>
-<h2 id="BookInOnePage-SpringTesting">Spring Testing</h2><p><a shape="rect" href="testing.html">Testing</a> is a crucial part of any development or integration work. The Spring Framework offers a number of features that makes it easy to test while using Spring for Inversion of Control which works with JUnit 3.x, JUnit 4.x, and <a shape="rect" class="external-link" href="http://testng.org" rel="nofollow">TestNG</a>.</p><p>We can use Spring for IoC and the Camel <a shape="rect" href="mock.html">Mock</a> and <a shape="rect" href="test.html">Test</a> endpoints to create sophisticated integration/unit tests that are easy to run and debug inside your IDE. &#160;There are three supported approaches for testing with Spring in Camel.</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>Testing Frameworks Supported</p></th><th colspan="1" rowspan="1" class="confl
 uenceTh"><p>Description</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Required Camel Test Dependencies</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>CamelSpringTestSupport</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated)</li><li>JUnit 4.x</li><li>TestNG - <strong>Camel 2.8</strong></li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Provided by org.apache.camel.test.CamelSpringTestSupport, org.apache.camel.test.junit4.CamelSpringTestSupport, and org.apache.camel.testng.CamelSpringTestSupport. &#160;These base classes provide <a shape="rect" href="camel-test.html#CamelTest-FeaturesProvidedbyCamelTestSupport">feature parity</a> with&#160;the simple CamelTestSupport classes from&#160;<a shape="rect" href="camel-test.html">Camel Test</a>&#160;but do not support Spring annotations on the test class such as <strong>@Autowired</strong>,&#160;<strong>@DirtiesContext</strong>, and&#160;<strong>@ContextC
 onfiguration</strong>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated) - camel-test-spring</li><li>JUnit 4.x&#160;- camel-test-spring</li><li>TestNG - camel-test-ng</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Plain Spring Test</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x</li><li>JUnit 4.x</li><li>TestNG</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Extend the abstract base classes (org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests,&#160;org.springframework.test.context.junit38.AbstractJUnit4SpringContextTests, etc.)&#160;provided in Spring Test or use the Spring Test JUnit4 runner. &#160;These approaches support both the Camel annotations and Spring annotations, but do not have <a shape="rect" href="camel-test.html#CamelTest-FeaturesProvidedbyCamelTestSupport">feature parity</a> with&#160;org.apache.camel.test.CamelTestSupport, org.apache.
 camel.test.junit4.CamelTestSupport, and org.apache.camel.testng.CamelSpringTestSupport.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated) - None</li><li>JUnit 4.x&#160;- None</li><li>TestNG - None</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Camel Enhanced Spring Test</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 4.x - <strong>Camel 2.10</strong></li><li>TestNG - <strong>Camel 2.10</strong></li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Use the org.apache.camel.test.junit4.CamelSpringJUnit4ClassRunner&#160;runner with the&#160;<strong>@RunWith</strong>&#160;annotation or extend org.apache.camel.testng.AbstractCamelTestNGSpringContextTests&#160;to enable <a shape="rect" href="camel-test.html#CamelTest-FeaturesProvidedbyCamelTestSupport">feature parity</a> with org.apache.camel.test.CamelTestSupport and org.apache.camel.test.junit4.CamelTestSupport and also support the full 
 suite of Spring Test annotations such as&#160;<strong>@Autowired</strong>,&#160;<strong>@DirtiesContext</strong>, and <strong>@ContextConfiguration</strong>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated) - camel-test-spring</li><li>JUnit 4.x&#160;- camel-test-spring</li><li>TestNG - camel-test-ng</li></ul></td></tr></tbody></table></div><h3 id="BookInOnePage-CamelSpringTestSupport">CamelSpringTestSupport</h3><p>org.apache.camel.test.CamelSpringTestSupport, org.apache.camel.test.junit4.CamelSpringTestSupport, and org.apache.camel.testng.CamelSpringTestSupport&#160;extend their non-Spring aware counterparts (org.apache.camel.test.CamelTestSupport, org.apache.camel.test.junit4.CamelTestSupport, and org.apache.camel.testng.CamelTestSupport) and deliver integration with Spring into your test classes. &#160;Instead of&#160;instantiating&#160;the CamelContext and routes programmatically, these classes rely on a Spring context to wire the needed com
 ponents together. &#160;If your test extends one of these classes, you must provide the Spring context by implementing the following method.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<h2 id="BookInOnePage-SpringTesting">Spring Testing</h2><p><a shape="rect" href="testing.html">Testing</a> is a crucial part of any development or integration work. The Spring Framework offers a number of features that makes it easy to test while using Spring for Inversion of Control which works with JUnit 3.x, JUnit 4.x, and <a shape="rect" class="external-link" href="http://testng.org" rel="nofollow">TestNG</a>.</p><p>We can use Spring for IoC and the Camel <a shape="rect" href="mock.html">Mock</a> and <a shape="rect" href="test.html">Test</a> endpoints to create sophisticated integration/unit tests that are easy to run and debug inside your IDE. &#160;There are three supported approaches for testing with Spring in Camel.</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>Testing Frameworks Supported</p></th><th colspan="1" rowspan="1" class="confl
 uenceTh"><p>Description</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Required Camel Test Dependencies</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><strong><code>CamelSpringTestSupport</code></strong></p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated)</li><li>JUnit 4.x</li><li>TestNG - <strong>Camel 2.8</strong></li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Provided by:</p><ul><li><strong><code>org.apache.camel.test.CamelSpringTestSupport</code></strong></li><li><strong><code>org.apache.camel.test.junit4.CamelSpringTestSupport</code></strong></li><li><strong><code>org.apache.camel.testng.CamelSpringTestSupport</code></strong></li></ul><p>These base classes provide <a shape="rect" href="camel-test.html#CamelTest-FeaturesProvidedbyCamelTestSupport">feature parity</a> with&#160;the simple&#160;<strong><code>CamelTestSupport</code></strong> classes from&#160;<a shape="rect" href="camel-test.ht
 ml">Camel Test</a>&#160;but do not support Spring annotations on the test class such as <strong><code>@Autowired</code></strong>,&#160;<strong><code>@DirtiesContext</code></strong>, and&#160;<strong><code>@ContextConfiguration</code></strong>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated) -&#160;<code>camel-test-spring</code></li><li>JUnit 4.x&#160;-&#160;<code>camel-test-spring</code></li><li>TestNG -&#160;<code>camel-test-ng</code></li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Plain Spring Test</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x</li><li>JUnit 4.x</li><li>TestNG</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Either extend the abstract base classes:</p><ul><li><strong><code>org.springframework.test.context.junit38.AbstractJUnit38SpringContextTests</code></strong></li><li><strong><code>org.springframework.test.context.junit38.AbstractJUnit4SpringContextTes
 ts</code></strong></li><li>etc.</li></ul><p>provided in Spring Test or use the Spring Test JUnit4 runner. &#160;</p><p>These approaches support both the Camel annotations and Spring annotations. However, they do NOT have <a shape="rect" href="camel-test.html#CamelTest-FeaturesProvidedbyCamelTestSupport">feature parity</a> with:</p><ul><li><strong><code>org.apache.camel.test.CamelTestSupport</code></strong></li><li><strong><code>org.apache.camel.test.junit4.CamelTestSupport</code></strong></li><li><strong><code>org.apache.camel.testng.CamelSpringTestSupport</code></strong></li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated) - None</li><li>JUnit 4.x&#160;- None</li><li>TestNG - None</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>Camel Enhanced Spring Test</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 4.x - <strong>Camel 2.10</strong></li><li>TestNG - <strong>Camel 2.10</strong></li></ul></td
 ><td colspan="1" rowspan="1" class="confluenceTd"><p>Either:</p><ul><li>use the&#160;<strong><code>org.apache.camel.test.junit4.CamelSpringJUnit4ClassRunner</code></strong> runner with the&#160;<strong><code>@RunWith</code></strong> annotation,</li><li>or extend&#160;<strong><code>org.apache.camel.testng.AbstractCamelTestNGSpringContextTests</code></strong> to enable <a shape="rect" href="camel-test.html#CamelTest-FeaturesProvidedbyCamelTestSupport">feature parity</a> with&#160;<strong><code>org.apache.camel.test.CamelTestSupport</code></strong> and&#160;<strong><code>org.apache.camel.test.junit4.CamelTestSupport</code></strong>. These classes support the full suite of Spring Test annotations such as&#160;<strong><code>@Autowired</code></strong>,&#160;<strong><code>@DirtiesContext</code></strong>, and&#160;<strong><code>@ContextConfiguration</code></strong>.</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><p>JUnit 3.x (deprecated) -&#160;<code>camel-test-spring</code>
 </p><p>JUnit 4.x&#160;-&#160;<code>camel-test-spring</code></p><p>TestNG -&#160;<code>camel-test-ng</code></p></td></tr></tbody></table></div><h3 id="BookInOnePage-CamelSpringTestSupport">CamelSpringTestSupport</h3><p>The following Spring test support classes:</p><ul><li><strong><code>org.apache.camel.test.CamelSpringTestSupport</code></strong></li><li><strong><code>org.apache.camel.test.junit4.CamelSpringTestSupport</code></strong>, and</li><li><strong><code>org.apache.camel.testng.CamelSpringTestSupport</code></strong></li></ul><p>extend their non-Spring aware counterparts:</p><ul><li><strong><code>org.apache.camel.test.CamelTestSupport</code></strong></li><li><strong><code>org.apache.camel.test.junit4.CamelTestSupport</code></strong>, and&#160;</li><li><strong><code>org.apache.camel.testng.CamelTestSupport</code></strong></li></ul><p>and deliver integration with Spring into your test classes. &#160;</p><p>Instead of&#160;instantiating&#160;the&#160;<strong><code>CamelContext</cod
 e></strong> and routes programmatically, these classes rely on a Spring context to wire the needed components together. &#160;If your test extends one of these classes, you must provide the Spring context by implementing the following method.</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[protected abstract AbstractApplicationContext createApplicationContext();
 ]]></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">
+</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. However, it does not support the features provided by the&#160;<strong><code>CamelSpringTestSupport</code></strong> 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-lin
 k" href="http://svn.apache.org/repos/asf/camel/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
@@ -3314,7 +3314,7 @@ public class FilterTest extends SpringRu
 }
 // 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">
+</div></div>Notice that we use&#160;<strong><code>@DirtiesContext</code></strong> 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><code>@ContextConfiguration</code></strong> to indicate that by default we should look for the file <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. The test context looks like:</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;
@@ -3338,11 +3338,11 @@ public class FilterTest extends SpringRu
 &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">
+</div></div>This test will load a Spring XML configuration file called <strong><code>FilterTest-context.xml</code></strong> from the classpath in the same package structure as the&#160;<strong><code>FilterTest</code></strong> class and initialize it along with any Camel routes we define inside it, then inject the <strong><code>CamelContext </code></strong>instance 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
 src/test/resources/org/apache/camel/spring/patterns/FilterTest-context.xml
 ]]></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">
+</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)
@@ -3391,54 +3391,48 @@ 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">
+</div></div>This is similar to the XML Config example above except that there is no XML file and instead the nested <strong><code>ContextConfig</code></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><code>@ContextConfiguration</code></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&#160;<strong><code>SpringJUnit4ClassRunner</code></strong> provided by Spring Test. &#160;This custom JUnit runner means you are free to choose your own class hierarchy while retaining all the capab
 ilities 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)
 @ContextConfiguration
 public class MyCamelTest {
-
     @Autowired
     protected CamelContext camelContext;
 
     @EndpointInject(uri = &quot;mock:foo&quot;)
     protected MockEndpoint foo;
 
-
     @Test
     @DirtiesContext
     public void testMocksAreValid() throws Exception {
-        ...       
+        // ...       
 
         foo.message(0).header(&quot;bar&quot;).isEqualTo(&quot;ABC&quot;);
-
         MockEndpoint.assertIsSatisfied(camelContext);
     }
 }
 ]]></script>
-</div></div><h4 id="BookInOnePage-PlainSpringTestusingJUnit4.1.xRunnerwithXMLConfig">Plain Spring Test using JUnit 4.1.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>When using Spring 4.1 onwards, you need to use the @BootstrapWith annotation to configure it to use Camel testing, as shown below.</p></div></div><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h4 id="BookInOnePage-PlainSpringTestUsingJUnit4.1.xRunnerWithXMLConfig">Plain Spring Test Using JUnit 4.1.x Runner With XML Config</h4><p>You can avoid extending Spring classes by using the&#160;<strong><code>SpringJUnit4ClassRunner</code></strong> 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>From <strong>Spring 4.1</strong>, you need to use the&#160;<strong><code>@BootstrapWith</code></strong> annotation to configure it to use Camel testing, as shown below.</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(CamelSpringJUnit4ClassRunner.class)
 @BootstrapWith(CamelTestContextBootstrapper.class)
 @ContextConfiguration
 public class MyCamelTest {
-
     @Autowired
     protected CamelContext camelContext;
 
     @EndpointInject(uri = &quot;mock:foo&quot;)
     protected MockEndpoint foo;
 
-
     @Test
     @DirtiesContext
     public void testMocksAreValid() throws Exception {
-        ...       
+        // ...       
 
         foo.message(0).header(&quot;bar&quot;).isEqualTo(&quot;ABC&quot;);
-
         MockEndpoint.assertIsSatisfied(camelContext);
     }
 }
 ]]></script>
-</div></div><h3 id="BookInOnePage-CamelEnhancedSpringTest"><span style="line-height: 1.5625;">Camel Enhanced Spring Test</span></h3><p>Using org.apache.camel.test.junit4.CamelSpringJUnit4ClassRunner&#160;runner with the&#160;<strong>@RunWith</strong>&#160;annotation or extending org.apache.camel.testng.AbstractCamelTestNGSpringContextTests provides the full feature set of Spring Test with support for the feature set provided in the CamelTestSupport classes. &#160;A number of Camel specific annotations have been developed in order to provide for declarative manipulation of the Camel context(s) involved in the test. &#160;These annotations free your test classes from having to inherit from the CamelSpringTestSupport classes and also reduce the amount of code required to customize the tests.</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Annotation Class</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p
 >Applies To</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Behavioir If Not Present</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Behavior If Present</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>org.apache.camel.test.spring.DisableJmx</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Class</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates if JMX should be globally disabled in the CamelContexts that are bootstrapped &#160;during the test through the use of Spring Test loaded application contexts.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>JMX is disabled</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>org.apache.camel.test.spring.ExcludeRoutes</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Cla
 ss</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates if certain route builder classes should be excluded from discovery. &#160;Initializes a org.apache.camel.spi.PackageScanClassResolver&#160;to exclude a set of given classes from being resolved. Typically this is used at test time to exclude certain routes,&#160;which might otherwise be just noisy, from being discovered and initialized.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Not enabled and no routes are excluded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>No routes are excluded</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>org.apache.camel.test.spring.LazyLoadTypeConverters (Deprecated)</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Class</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates if the&#160;CamelContexts that are bootstrapped during the test through the use of Spring Test&#160;loaded application contexts should
  use lazy loading of type converters.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Type converters are not lazy loaded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Type converters are not lazy loaded</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>org.apache.camel.test.spring.MockEndpoints</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Class</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 "*" which matches all endpoints. &#160;See&#160;org.apache.camel.impl.InterceptSendToMockEndpointStrategy&#160;for&#160;more details on the registration of the mock endpoints.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Not enabled</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>All endpoints are sniffed and recorded in a mock endpoint.</p></td></tr><tr><td colspan="1" rowspan="1" class="
 confluenceTd"><p>org.apache.camel.test.spring.MockEndpointsAndSkip</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Class</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 "*", which matches all endpoints. &#160;See&#160;<a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategy.java?view=markup">org.apache.camel.impl.InterceptSendToMockEndpointStrategy</a>&#160;for&#160;more details on the registration of the mock endpoints. &#160;This annotation will also skip sending the message to matched endpoints as well.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Not enabled</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>All endpoints are sniffed and recorded in a mock endpoint. &#160;The original endpoint is not invoked.</p></
 td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>org.apache.camel.test.spring.ProvidesBreakpoint</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Method</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates that the annotated method returns an&#160;org.apache.camel.spi.Breakpoint&#160;for use in the test.&#160; Useful for intercepting&#160;traffic to all endpoints or simply for setting a break point in an IDE for debugging.&#160; The method must&#160;be public, static, take no arguments, and return org.apache.camel.spi.Breakpoint.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>N/A</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The returned Breakpoint is registered in the CamelContext(s)</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>org.apache.camel.test.spring.ShutdownTimeout</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Class</p></td><td colspan="1" rowspan="1" class="confluence
 Td"><p>Indicates to set the shutdown timeout of all CamelContexts instantiated through the&#160;use of Spring Test loaded application contexts.&#160; If no annotation is used, the timeout is&#160;automatically reduced to 10 seconds by the test framework.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>10 seconds</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>10 seconds</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>org.apache.camel.test.spring.UseAdviceWith</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Class</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates the use of adviceWith() within the test class.&#160; If a class is annotated with&#160;this annotation and UseAdviceWith#value()&#160;returns true, any&#160;CamelContexts bootstrapped during the test through the use of Spring Test loaded&#160;application contexts will not be started automatically.&#160; The test author is responsible for&#160;injecti
 ng the Camel contexts into the test and executing CamelContext#start()&#160;on them&#160;at the appropriate time after any advice has been applied to the routes in the CamelContext(s).</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>CamelContexts do not automatically start.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>CamelContexts do not automatically start.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">org.apache.camel.test.spring.UseOverridePropertiesWithPropertiesComponent</td><td colspan="1" rowspan="1" class="confluenceTd">Method</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong>Indicates that the annotated method returns a java.util.Properties for use in the test, and that those properties override any existing properties configured on the PropertiesComponent</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd">Override properties</td></tr>
 </tbody></table></div><p>The following example illustrates the use of the <strong>@MockEndpoints</strong>&#160;annotation in order to setup mock endpoints as interceptors on all endpoints using the Camel Log component and the <strong>@DisableJmx</strong> annotation to enable JMX which is disabled during tests by default. &#160;Note that we still use the <strong>@DirtiesContext</strong> annotation to ensure that the CamelContext, routes, and mock endpoints are reinitialized between test methods.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="BookInOnePage-CamelEnhancedSpringTest"><span style="line-height: 1.5625;">Camel Enhanced Spring Test</span></h3><p>Using the <strong><code>org.apache.camel.test.junit4.CamelSpringJUnit4ClassRunner</code></strong> runner with the&#160;<strong><code>@RunWith</code></strong> annotation or extending&#160;<strong><code>org.apache.camel.testng.AbstractCamelTestNGSpringContextTests</code></strong> provides the full feature set of Spring Test with support for the feature set provided in the&#160;<strong><code>CamelTestSupport</code></strong> classes. &#160;</p><p>A number of Camel specific annotations have been developed in order to provide for declarative manipulation of the Camel context(s) involved in the test. &#160;These annotations free your test classes from having to inherit from the&#160;<strong><code>CamelSpringTestSupport</code></strong> classes and also reduce the amount of code required to customize the tests.</p><div class="table-wrap"><table class="conflue
 nceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Annotation Class</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Applies To</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Behavioir If Not Present</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Behavior If Present</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.apache.camel.test.spring.DisableJmx</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Class</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates if JMX should be globally disabled in the CamelContexts that are bootstrapped &#160;during the test through the use of Spring Test loaded application contexts.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>JMX is disabled</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><code>org.apache.camel.test.spring.ExcludeRoutes</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Class</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates if certain route builder classes should be excluded from discovery. &#160;Initializes a&#160;<strong><code>org.apache.camel.spi.PackageScanClassResolver</code></strong> to exclude a set of given classes from being resolved. Typically this is used at test time to exclude certain routes,&#160;which might otherwise be just noisy, from being discovered and initialized.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Not enabled and no routes are excluded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>No routes are excluded</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.apache.camel.test.spring.LazyLoadTypeConverters</code></p></td><td colspan="1" rowspan="1" cla
 ss="confluenceTd"><p><code>Class</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><span style="color: rgb(255,0,0);"><strong>Deprecated.</strong> </span></p><p>Indicates if the&#160;CamelContexts that are bootstrapped during the test through the use of Spring Test&#160;loaded application contexts should use lazy loading of type converters.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Type converters are not lazy loaded</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Type converters are not lazy loaded</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.apache.camel.test.spring.MockEndpoints</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Class</code></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&#160;<strong><code>"*"</code></strong> which matches all endpoints. &#1
 60;See&#160;<strong><code>org.apache.camel.impl.InterceptSendToMockEndpointStrategy</code></strong> for&#160;more details on the registration of the mock endpoints.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Not enabled</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>All endpoints are sniffed and recorded in a mock endpoint.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.apache.camel.test.spring.MockEndpointsAndSkip</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Class</code></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 <strong><code>"*"</code></strong>, which matches all endpoints. &#160;See&#160;<a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToMockEndpointStrategy.java?view=mar
 kup">org.apache.camel.impl.InterceptSendToMockEndpointStrategy</a>&#160;for&#160;more details on the registration of the mock endpoints. &#160;This annotation will also skip sending the message to matched endpoints as well.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Not enabled</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>All endpoints are sniffed and recorded in a mock endpoint. &#160;The original endpoint is not invoked.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.apache.camel.test.spring.ProvidesBreakpoint</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Method</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates that the annotated method returns an&#160;<strong><code>org.apache.camel.spi.Breakpoint</code></strong> for use in the test.&#160; Useful for intercepting&#160;traffic to all endpoints or simply for setting a break point in an IDE for debugging.&#160; The me
 thod must&#160;be public, static, take no arguments, and return <strong><code>org.apache.camel.spi.Breakpoint</code></strong>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>N/A</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The returned&#160;<strong><code>Breakpoint</code></strong> is registered in the CamelContext(s)</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.apache.camel.test.spring.ShutdownTimeout</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Class</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates to set the shutdown timeout of all CamelContexts instantiated through the&#160;use of Spring Test loaded application contexts.&#160; If no annotation is used, the timeout is&#160;automatically reduced to 10 seconds by the test framework.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>10 seconds</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>10 se
 conds</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>org.apache.camel.test.spring.UseAdviceWith</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Class</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Indicates the use of&#160;<strong><code>adviceWith()</code></strong> within the test class.&#160; If a class is annotated with&#160;this annotation and&#160;<strong><code>UseAdviceWith#value()</code></strong> returns true, any&#160;CamelContexts bootstrapped during the test through the use of Spring Test loaded&#160;application contexts will not be started automatically.&#160;</p><p>The test author is responsible for&#160;injecting the Camel contexts into the test and executing&#160;<strong><code>CamelContext#start()</code></strong> on them&#160;at the appropriate time after any advice has been applied to the routes in the CamelContext(s).</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>CamelContexts do no
 t automatically start.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>CamelContexts do not automatically start.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>org.apache.camel.test.spring.UseOverridePropertiesWithPropertiesComponent</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>Method</code></td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.16:</strong>Indicates that the annotated method returns a&#160;<strong><code>java.util.Properties</code></strong> for use in the test, and that those properties override any existing properties configured on the <strong><code>PropertiesComponent</code></strong>.</td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd">Override properties</td></tr></tbody></table></div><p>The following example illustrates the use of the <strong><code>@MockEndpoints</code></strong> annotation in order to setup mock endpoints as interc
 eptors on all endpoints using the Camel Log component and the <strong><code>@DisableJmx</code></strong> annotation to enable JMX which is disabled during tests by default. &#160;</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">Note: we still use the <strong><code>@DirtiesContext</code></strong> annotation to ensure that the CamelContext, routes, and mock endpoints are reinitialized between test methods.</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(CamelSpringJUnit4ClassRunner.class)
 @BootstrapWith(CamelTestContextBootstrapper.class)
 @ContextConfiguration
@@ -3446,7 +3440,6 @@ public class MyCamelTest {
 @MockEndpoints(&quot;log:*&quot;)
 @DisableJmx(false)
 public class CamelSpringJUnit4ClassRunnerPlainTest {
-
     @Autowired
     protected CamelContext camelContext2;
 
@@ -3463,7 +3456,6 @@ public class CamelSpringJUnit4ClassRunne
 
     @Test
     public void testPositive() throws Exception {
-
         mockC.expectedBodiesReceived(&quot;David&quot;);
         mockLog.expectedBodiesReceived(&quot;Hello David&quot;);
 
@@ -3472,10 +3464,9 @@ public class CamelSpringJUnit4ClassRunne
         MockEndpoint.assertIsSatisfied(camelContext);
     }
 ]]></script>
-</div></div><h3 id="BookInOnePage-AddingmoreMockexpectations">Adding more Mock expectations</h3><p>If you wish to programmatically add any new assertions to your test you can easily do so with the following. Notice how we use @EndpointInject to inject a Camel endpoint into our code then the <a shape="rect" href="mock.html">Mock</a> API to add an expectation on a specific message.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="BookInOnePage-AddingMoreMockExpectations">Adding More Mock Expectations</h3><p>If you wish to programmatically add any new assertions to your test you can easily do so with the following. Notice how we use&#160;<strong><code>@EndpointInject</code></strong> to inject a Camel endpoint into our code then the <a shape="rect" href="mock.html">Mock</a> API to add an expectation on a specific 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[@ContextConfiguration
 public class MyCamelTest extends AbstractJUnit38SpringContextTests {
-
     @Autowired
     protected CamelContext camelContext;
 
@@ -3490,10 +3481,9 @@ public class MyCamelTest extends Abstrac
     }
 }
 ]]></script>
-</div></div><h3 id="BookInOnePage-Furtherprocessingthereceivedmessages">Further processing the received messages</h3><p>Sometimes once a <a shape="rect" href="mock.html">Mock</a> endpoint has received some messages you want to then process them further to add further assertions that your test case worked as you expect.</p><p>So you can then process the received message exchanges if you like...</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="BookInOnePage-FurtherProcessingtheReceivedMessages">Further Processing the Received Messages</h3><p>Sometimes once a <a shape="rect" href="mock.html">Mock</a> endpoint has received some messages you want to then process them further to add further assertions that your test case worked as you expect.</p><p>So you can then process the received message exchanges if you like...</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[@ContextConfiguration
 public class MyCamelTest extends AbstractJUnit38SpringContextTests {
-
     @Autowired
     protected CamelContext camelContext;
 
@@ -3509,14 +3499,14 @@ public class MyCamelTest extends Abstrac
         List&lt;Exchange&gt; list = foo.getReceivedExchanges();
         for (Exchange exchange : list) {
             Message in = exchange.getIn();
-            ...
+            // ...
         }
     }
 }
 ]]></script>
-</div></div><h3 id="BookInOnePage-Sendingandreceivingmessages">Sending and receiving messages</h3><p>It might be that the <a shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a> you have defined in either <a shape="rect" href="spring.html">Spring</a> XML or using the Java <a shape="rect" href="dsl.html">DSL</a> do all of the sending and receiving and you might just work with the <a shape="rect" href="mock.html">Mock</a> endpoints as described above. However sometimes in a test case its useful to explicitly send or receive messages directly.</p><p>To send or receive messages you should use the <a shape="rect" href="bean-integration.html">Bean Integration</a> mechanism. For example to send messages inject a ProducerTemplate using the @EndpointInject annotation then call the various send methods on this object to send a message to an endpoint. To consume messages use the @MessageDriven annotation on a method to have the method invoked when a mess
 age is received.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="BookInOnePage-SendingandReceivingMessages">Sending and Receiving Messages</h3><p>It might be that the <a shape="rect" href="enterprise-integration-patterns.html">Enterprise Integration Patterns</a> you have defined in either <a shape="rect" href="spring.html">Spring</a> XML or using the Java <a shape="rect" href="dsl.html">DSL</a> do all of the sending and receiving and you might just work with the <a shape="rect" href="mock.html">Mock</a> endpoints as described above. However sometimes in a test case its useful to explicitly send or receive messages directly.</p><p>To send or receive messages you should use the <a shape="rect" href="bean-integration.html">Bean Integration</a> mechanism. For example to send messages inject a&#160;<strong><code>ProducerTemplate</code></strong> using the&#160;<strong><code>@EndpointInject</code></strong> annotation then call the various send methods on this object to send a message to an endpoint. To consume messages use the&#160;<
 strong><code>@MessageDriven</code></strong> annotation on a method to have the method invoked when a message is received.</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 Foo {
-  @EndpointInject(uri=&quot;activemq:foo.bar&quot;)
+  @EndpointInject(uri = &quot;activemq:foo.bar&quot;)
   ProducerTemplate producer;
 
   public void doSomething() {
@@ -3527,7 +3517,7 @@ public class MyCamelTest extends Abstrac
   // lets consume messages from the &#39;cheese&#39; queue
   @MessageDriven(uri=&quot;activemq:cheese&quot;)
   public void onCheese(String name) {
-    ...
+    // ...
   }
 }
 ]]></script>
@@ -3940,11 +3930,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>
 

[... 41 lines stripped ...]