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 Jun 29 23:19:25 2017 @@ -2757,7 +2757,7 @@ public class DebugBlueprintTest extends <!-- end::example[] --> ]]></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 & 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>, <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"> +<h2 id="BookInOnePage-CamelTest">Camel Test</h2><p>As a simple alternative to using <a shape="rect" href="cdi-testing.html">CDI Testing</a>, <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 <strong><code>camel-test</code></strong> JAR is using JUnit. There is an alternative <strong><code>camel-testng</code></strong> JAR (from <strong>Camel 2.8</strong>) using the <a shape="rect" class="external-link" href="http://testng.org/doc/index.html" rel="nofo llow">TestNG</a> test framework.</p></div></div><h3 id="BookInOnePage-Addingtoyourpom.xml">Adding to your <code>pom.xml</code></h3><p>To get started using Camel Test you will need to add an entry to your <strong><code>pom.xml</code></strong>:</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[<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test</artifactId> @@ -2773,7 +2773,7 @@ public class DebugBlueprintTest extends <scope>test</scope> </dependency> ]]></script> -</div></div><p>You might also want to add slf4j and log4j to ensure nice logging messages (and maybe adding a <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/log4j.properties">log4j.properties</a> file into your src/test/resources directory).</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>You might also want to add <strong><code>slf4j</code></strong> and <strong><code>log4j</code></strong> to ensure nice logging messages (and maybe adding a <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/log4j.properties">log4j.properties</a> file into your <strong><code>src/test/resources</code></strong> directory).</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[<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> @@ -2785,7 +2785,7 @@ public class DebugBlueprintTest extends <scope>test</scope> </dependency> ]]></script> -</div></div><h3 id="BookInOnePage-Writingyourtest">Writing your test</h3><p>You firstly need to derive from the class <strong>CamelTestSupport</strong> (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) and typically you will need to override the <strong>createRouteBuilder()</strong> or <strong>createRouteBuilders()</strong> 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"> +</div></div><h3 id="BookInOnePage-Writingyourtest">Writing your test</h3><p>You firstly need to derive from the class <strong><code>CamelTestSupport</code></strong> <strong>(<code>org.apache.camel.test.CamelTestSupport</code>, <code>org.apache.camel.test.junit4.CamelTestSupport</code></strong>, or <strong><code>org.apache.camel.testng.CamelTestSupport</code></strong> for JUnit 3.x, JUnit 4.x, and TestNG, respectively) and typically you will need to override the <strong><strong><code>createRouteBuilder()</code></strong> or <strong><code>createRouteBuilders()</code></strong></strong> 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 { @@ -2832,7 +2832,10 @@ 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.  The classes provide a number of methods that allow a test to alter the configuration of the CamelContext used.  The following table describes the available customization methods a nd the default behavior of tests that are built from a <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 <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.  <strong>createRouteBuilder()</strong> or <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> and return true.  This helps in knowing the adviceWith is to be used, and the CamelContext will not be started before the advice with takes place. This delay helps by ensuring the advice with has been property setup before the CamelContext 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.  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 <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.  The default filter is null which disables this feature.  Return "*"  to match all endpoints.  See org.apache.camel.impl.Intercept SendToMockEndpointStrategy for 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 <strong>debugBefore(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label)</strong> and <br clear="none" class="atl-forced-newline"> <strong>debugAfter(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label, long timeTaken)</strong> methods are invoked for each processor in the registered routes.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disabled.  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.  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.  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"> +</div></div><strong>Note</strong>: 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 <code>CamelTestSupport</code></h4><p>The various <strong><code>CamelTestSupport</code></strong> classes provide a standard set of behaviors relating to the <strong><code>CamelContext</code></strong> used to host the route(s) under test.  The classes provide a number of methods that allow a test to alter the configuration of the  <strong><code>CamelContext</code></strong> used.  The following table describes the available customization methods and the default behavior of tests that are built from a <strong><code>CamelTestSupport</code></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><code>boolean isUseRouteBuilder()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the route builders returned from either <strong><code>createRouteBuilder()</code></strong> or <strong><code>createRouteBuilders()</code></strong> should be added to the <strong><code>CamelContext</code></strong> for the test to be started.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>R eturns <strong><code>true</code></strong>. </p><p><strong><strong><code>createRouteBuilder()</code></strong> or <strong><code>createRouteBuilders()</code></strong></strong> are invoked and the <strong><code>CamelContext</code></strong> is started automatically.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean isUseAdviceWith()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the <strong><code>CamelContext</code></strong> use in the test should be automatically started before test methods are invoked.</p><p><br clear="none" class="atl-forced-newline"> Override when using <a shape="rect" href="advicewith.html">advice with</a> and return <strong><code>true</code></strong>.  This helps in knowing the <strong><code>adviceWith()</code></strong> is to be used, and the <strong><code>CamelContext</code></strong> will not be started before the advice with takes place. This delay helps by ensuring th e advice with has been property setup before the <strong><code>CamelContext</code></strong> 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 <strong><code>CamelContext</code></strong> 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 <strong><code>false</code></strong>. </p><p>The <strong><code>CamelContext</code></strong> is started automatically before test methods are invoked.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean isCreateCamelContextPerClass()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>See <a shape="rect" href="#BookInOnePage-SetupCamelContextonceperclass,orperevery testmethod">Setup CamelContext once per class, or per every test method</a>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The <strong><code>CamelContext</code></strong> and routes are recreated for each test method.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String isMockEndpoints()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Triggers the auto-mocking of endpoints whose URIs match the provided filter.  The default filter is <strong><code>null</code></strong> which disables this feature.  </p><p>Return <strong><code>"*"</code></strong>  to match all endpoints.  </p><p>See <strong><code>org.apache.camel.impl.InterceptSendToMockEndpointStrategy</code></strong> for 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><code>boolean isUseDebugger()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If this method returns <strong><code>true</code></strong>, the methods:</p><ul><li><strong><code>debugBefore(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label)</code></strong></li><li><strong> <code>debugAfter(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label, long timeTaken)</code></strong></li></ul><p>are invoked for each processor in the registered routes.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disabled</p><p>The methods are not invoked during the test.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>int getShutdownTimeout()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns the number of seconds that Camel should wait for graceful shutdown.  </p><p>Useful for decreasing test times when a message is stil l in flight at the end of the test.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>10 seconds</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean useJmx()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If JMX should be disabled on the <strong><code>CamelContext</code></strong> 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><code>JndiRegistry createRegistry()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Provides a hook for adding objects into the registry.  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><code>useOverridePropertiesWithPropertiesComponent</code></p></td><td colspa n="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><strong><code>null</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ignoreMissingLocationWithPropertiesComponent</code></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><strong><code>null</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean isDumpRouteCoverage</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.16:</strong> If enabled, then Camel will dump all route coverage statistics into XML files 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.</p></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><code>jndi.properties</code></strong> file in your <strong><code>src/test/resources</co de></strong> directory so that there is a default registry available to initialize 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><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[java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory +]]></script> +</div></div><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. <strong><code>AvailablePortFinder</code></strong> provides methods for finding unused port numbers at run time.</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 int port1 = AvailablePortFinder.getNextAvailable(); /* @@ -2841,7 +2844,7 @@ int port1 = AvailablePortFinder.getNextA */ int port2 = AvailablePortFinder.getNextAvailable(port1 + 1); ]]></script> -</div></div><h3 id="BookInOnePage-SetupCamelContextonceperclass,orpereverytestmethod">Setup CamelContext once per class, or per every test method</h3><p><strong>Available as of Camel 2.8</strong></p><p>The <a shape="rect" href="camel-test.html">Camel Test</a> kit will by default setup and shutdown <a shape="rect" href="camelcontext.html">CamelContext</a> per every test method in your test class. So for example if you have 3 test methods, then <a shape="rect" href="camelcontext.html">CamelContext</a> is started and shutdown after each test, that is 3 times.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">TestNG</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This feature is also supported in camel-testng</p></div></div><div class="confluence-information-macro confluence-information-macro-warning"><p class="title">Beware</p><span class ="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using this the <a shape="rect" href="camelcontext.html">CamelContext</a> will keep state between tests, so have that in mind. So if your unit tests start to fail for no apparent reason, it could be due this fact. So use this feature with a bit of care.</p></div></div><p>You may want to do this once, to share the <a shape="rect" href="camelcontext.html">CamelContext</a> between test methods, to speedup unit testing. This requires to use JUnit 4! In your unit test method you have to extend the <code>org.apache.camel.test.junit4.CamelTestSupport</code> or the <code>org.apache.camel.test.junit4.CamelSpringTestSupport</code> test class and override the <code>isCreateCamelContextPerClass</code> method and return <code>true</code> as shown in the following example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panel Header pdl" style="border-bottom-width: 1px;"><b>Setup CamelContext once per class</b></div><div class="codeContent panelContent pdl"> +</div></div><h3 id="BookInOnePage-SetupCamelContextonceperclass,orpereverytestmethod">Setup CamelContext once per class, or per every test method</h3><p><strong>Available as of Camel 2.8</strong></p><p>The <a shape="rect" href="camel-test.html">Camel Test</a> kit will by default setup and shutdown <a shape="rect" href="camelcontext.html">CamelContext</a> per every test method in your test class. So for example if you have 3 test methods, then <a shape="rect" href="camelcontext.html">CamelContext</a> is started and shutdown after each test, that is 3 times.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">TestNG</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This feature is also supported in <strong><code>camel-testng</code></strong></p></div></div><div class="confluence-information-macro confluence-information-macro-warning"><p class="title">Beware</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using this the <a shape="rect" href="camelcontext.html">CamelContext</a> will keep state between tests, so have that in mind. So if your unit tests start to fail for no apparent reason, it could be due this fact. So use this feature with a bit of care.</p></div></div><p>You may want to do this once, to share the <a shape="rect" href="camelcontext.html">CamelContext</a> between test methods, to speedup unit testing. This requires the use of JUnit 4! In your unit test method you have to extend the <strong><code>org.apache.camel.test.junit4.CamelTestSupport</code></strong> or the <strong><code>org.apache.camel.test.junit4.CamelSpringTestSupport</code></strong> test class and override the <strong><code>isCreateCamelContextPerClass</code></strong> method and return <code>true</code> as shown in the following examp le:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Setup CamelContext once per class</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ public class FilterCreateCamelContextPerClassTest extends CamelTestSupport { @@ -2883,10 +2886,7 @@ public class FilterCreateCamelContextPer } } ]]></script> -</div></div><h3 id="BookInOnePage-SeeAlso.1">See Also</h3><ul><li><a shape="rect" href="testing.html">Testing</a></li><li><a shape="rect" href="mock.html">Mock</a></li><li><a shape="rect" href="test.html">Test</a></li></ul><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[java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory -]]></script> -</div></div> +</div></div><h3 id="BookInOnePage-SeeAlso.1">See Also</h3><ul><li><a shape="rect" href="testing.html">Testing</a></li><li><a shape="rect" href="mock.html">Mock</a></li><li><a shape="rect" href="test.html">Test</a></li></ul><p> </p> <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.  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 the simple <strong><code>CamelTestSupport</code></strong> classes from <a shape="rect" href="camel-test.ht ml">Camel Test</a> but do not support Spring annotations on the test class such as <strong><code>@Autowired</code></strong>, <strong><code>@DirtiesContext</code></strong>, and <strong><code>@ContextConfiguration</code></strong>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>JUnit 3.x (deprecated) - <code>camel-test-spring</code></li><li>JUnit 4.x - <code>camel-test-spring</code></li><li>TestNG - <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.  </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 - 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 <strong><code>org.apache.camel.test.junit4.CamelSpringJUnit4ClassRunner</code></strong> > runner with the <strong><code>@RunWith</code></strong> >annotation,</li><li>or >extend <strong><code>org.apache.camel.testng.AbstractCamelTestNGSpringContextTests</code></strong> > to enable <a shape="rect" >href="camel-test.html#CamelTest-FeaturesProvidedbyCamelTestSupport">feature >parity</a> >with <strong><code>org.apache.camel.test.CamelTestSupport</code></strong> > >and <strong><code>org.apache.camel.test.junit4.CamelTestSupport</code></strong>. > These classes support the full suite of Spring Test annotations such >as <strong><code>@Autowired</code></strong>, <strong><code>@DirtiesContext</code></strong>, > >and <strong><code>@ContextConfiguration</code></strong>.</li></ul></td><td > colspan="1" rowspan="1" class="confluenceTd"><p>JUnit 3.x (deprecated) >- <code>camel-test-spring</code> </p><p>JUnit 4.x - <code>camel-test-spring</code></p><p>TestNG - <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 </li><li><strong><code>org.apache.camel.testng.CamelTestSupport</code></strong></li></ul><p>and deliver integration with Spring into your test classes.  </p><p>Instead of instantiating the <strong><code>CamelContext</cod e></strong> and routes programmatically, these classes rely on a Spring context to wire the needed components together.  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> @@ -3545,11 +3545,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> </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.rbtoc1497680425587 {padding: 0px;} -div.rbtoc1497680425587 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1497680425587 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1498778265517 {padding: 0px;} +div.rbtoc1498778265517 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1498778265517 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1497680425587"> +/*]]>*/</style></p><div class="toc-macro rbtoc1498778265517"> <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> @@ -5664,11 +5664,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.rbtoc1497680425919 {padding: 0px;} -div.rbtoc1497680425919 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1497680425919 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1498778265844 {padding: 0px;} +div.rbtoc1498778265844 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1498778265844 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style><div class="toc-macro rbtoc1497680425919"> +/*]]>*/</style><div class="toc-macro rbtoc1498778265844"> <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> @@ -16871,11 +16871,11 @@ template.send("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.rbtoc1497680430558 {padding: 0px;} -div.rbtoc1497680430558 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1497680430558 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1498778285286 {padding: 0px;} +div.rbtoc1498778285286 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1498778285286 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1497680430558"> +/*]]>*/</style></p><div class="toc-macro rbtoc1498778285286"> <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/camel-test.html ============================================================================== --- websites/production/camel/content/camel-test.html (original) +++ websites/production/camel/content/camel-test.html Thu Jun 29 23:19:25 2017 @@ -86,7 +86,7 @@ <tbody> <tr> <td valign="top" width="100%"> -<div class="wiki-content maincontent"><h2 id="CamelTest-CamelTest">Camel Test</h2><p>As a simple alternative to using <a shape="rect" href="cdi-testing.html">CDI Testing</a>, <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="CamelTest-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="CamelTest-JUnit">JUnit</h4><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +<div class="wiki-content maincontent"><h2 id="CamelTest-CamelTest">Camel Test</h2><p>As a simple alternative to using <a shape="rect" href="cdi-testing.html">CDI Testing</a>, <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 <strong><code>camel-test</code></strong> JAR is using JUnit. There is an alternative <strong><code>camel-testng</code></strong> JAR (from <strong>Camel 2.8</strong>) using the <a shape="rect" class="external-link" href="http://te stng.org/doc/index.html" rel="nofollow">TestNG</a> test framework.</p></div></div><h3 id="CamelTest-Addingtoyourpom.xml">Adding to your <code>pom.xml</code></h3><p>To get started using Camel Test you will need to add an entry to your <strong><code>pom.xml</code></strong>:</p><h4 id="CamelTest-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[<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test</artifactId> @@ -102,7 +102,7 @@ <scope>test</scope> </dependency> ]]></script> -</div></div><p>You might also want to add slf4j and log4j to ensure nice logging messages (and maybe adding a <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/log4j.properties">log4j.properties</a> file into your src/test/resources directory).</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> +</div></div><p>You might also want to add <strong><code>slf4j</code></strong> and <strong><code>log4j</code></strong> to ensure nice logging messages (and maybe adding a <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-test/src/test/resources/log4j.properties">log4j.properties</a> file into your <strong><code>src/test/resources</code></strong> directory).</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[<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> @@ -114,7 +114,7 @@ <scope>test</scope> </dependency> ]]></script> -</div></div><h3 id="CamelTest-Writingyourtest">Writing your test</h3><p>You firstly need to derive from the class <strong>CamelTestSupport</strong> (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) and typically you will need to override the <strong>createRouteBuilder()</strong> or <strong>createRouteBuilders()</strong> 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"> +</div></div><h3 id="CamelTest-Writingyourtest">Writing your test</h3><p>You firstly need to derive from the class <strong><code>CamelTestSupport</code></strong> <strong>(<code>org.apache.camel.test.CamelTestSupport</code>, <code>org.apache.camel.test.junit4.CamelTestSupport</code></strong>, or <strong><code>org.apache.camel.testng.CamelTestSupport</code></strong> for JUnit 3.x, JUnit 4.x, and TestNG, respectively) and typically you will need to override the <strong><strong><code>createRouteBuilder()</code></strong> or <strong><code>createRouteBuilders()</code></strong></strong> 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 { @@ -161,7 +161,10 @@ 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="CamelTest-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.  The classes provide a number of methods that allow a test to alter the configuration of the CamelContext used.  The following table describes the available customization methods and t he default behavior of tests that are built from a <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 <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.  <strong>createRouteBuilder()</strong> or <strong>createRouteBuilders()</strong> are invoked and the CamelContext is started automatically.</p></td></tr><tr><td colspan="1" r owspan="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> and return true.  This helps in knowing the adviceWith is to be used, and the CamelContext will not be started before the advice with takes place. This delay helps by ensuring the advice with has been property setup before the CamelContext 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.  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 <a shape="rect" href="#CamelTest-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.  The default filter is null which disables this feature.  Return "*"  to match all endpoints.  See org.apache.camel.impl.InterceptSendToMo ckEndpointStrategy for 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 <strong>debugBefore(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label)</strong> and <br clear="none" class="atl-forced-newline"> <strong>debugAfter(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label, long timeTaken)</strong> methods are invoked for each processor in the registered routes.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disabled.  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.  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.  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 files 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="CamelTest-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/resources</strong> d irectory 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="CamelTest-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"> +</div></div><strong>Note</strong>: 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="CamelTest-FeaturesProvidedbyCamelTestSupport">Features Provided by <code>CamelTestSupport</code></h4><p>The various <strong><code>CamelTestSupport</code></strong> classes provide a standard set of behaviors relating to the <strong><code>CamelContext</code></strong> used to host the route(s) under test.  The classes provide a number of methods that allow a test to alter the configuration of the <str ong><code>CamelContext</code></strong> used.  The following table describes the available customization methods and the default behavior of tests that are built from a <strong><code>CamelTestSupport</code></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><code>boolean isUseRouteBuilder()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the route builders returned from either <strong><code>createRouteBuilder()</code></strong> or <strong><code>createRouteBuilders()</code></strong> should be added to the <strong><code>CamelContext</code></strong> for the test to be started.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Retur ns <strong><code>true</code></strong>. </p><p><strong><strong><code>createRouteBuilder()</code></strong> or <strong><code>createRouteBuilders()</code></strong></strong> are invoked and the <strong><code>CamelContext</code></strong> is started automatically.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean isUseAdviceWith()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the <strong><code>CamelContext</code></strong> use in the test should be automatically started before test methods are invoked.</p><p><br clear="none" class="atl-forced-newline"> Override when using <a shape="rect" href="advicewith.html">advice with</a> and return <strong><code>true</code></strong>.  This helps in knowing the <strong><code>adviceWith()</code></strong> is to be used, and the <strong><code>CamelContext</code></strong> will not be started before the advice with takes place. This delay helps by ensuring the ad vice with has been property setup before the <strong><code>CamelContext</code></strong> 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 <strong><code>CamelContext</code></strong> 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 <strong><code>false</code></strong>. </p><p>The <strong><code>CamelContext</code></strong> is started automatically before test methods are invoked.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean isCreateCamelContextPerClass()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>See <a shape="rect" href="#CamelTest-SetupCamelContextonceperclass,orpereverytestmeth od">Setup CamelContext once per class, or per every test method</a>.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The <strong><code>CamelContext</code></strong> and routes are recreated for each test method.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>String isMockEndpoints()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Triggers the auto-mocking of endpoints whose URIs match the provided filter.  The default filter is <strong><code>null</code></strong> which disables this feature.  </p><p>Return <strong><code>"*"</code></strong>  to match all endpoints.  </p><p>See <strong><code>org.apache.camel.impl.InterceptSendToMockEndpointStrategy</code></strong> for 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><code>boolean isUseDe bugger()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If this method returns <strong><code>true</code></strong>, the methods:</p><ul><li><strong><code>debugBefore(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label)</code></strong></li><li><strong> <code>debugAfter(Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label, long timeTaken)</code></strong></li></ul><p>are invoked for each processor in the registered routes.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disabled</p><p>The methods are not invoked during the test.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>int getShutdownTimeout()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Returns the number of seconds that Camel should wait for graceful shutdown.  </p><p>Useful for decreasing test times when a message is still in fli ght at the end of the test.</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>10 seconds</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean useJmx()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If JMX should be disabled on the <strong><code>CamelContext</code></strong> 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><code>JndiRegistry createRegistry()</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Provides a hook for adding objects into the registry.  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><code>useOverridePropertiesWithPropertiesComponent</code></p></td><td colspan="1" ro wspan="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><strong><code>null</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ignoreMissingLocationWithPropertiesComponent</code></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><strong><code>null</code></strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>boolean isDumpRouteCoverage</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.16:</strong> If enabled, then Camel will dump all route coverage statistics into XML files in the target/camel-route-coverage director y. 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.</p></td><td colspan="1" rowspan="1" class="confluenceTd">Disabled</td></tr></tbody></table></div><h3 id="CamelTest-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><code>jndi.properties</code></strong> file in your <strong><code>src/test/resources</code></strong> directory so that there is a default registry available to initialize 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><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[java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory +]]></script> +</div></div><h3 id="CamelTest-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. <strong><code>AvailablePortFinder</code></strong> provides methods for finding unused port numbers at run time.</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 int port1 = AvailablePortFinder.getNextAvailable(); /* @@ -170,7 +173,7 @@ int port1 = AvailablePortFinder.getNextA */ int port2 = AvailablePortFinder.getNextAvailable(port1 + 1); ]]></script> -</div></div><h3 id="CamelTest-SetupCamelContextonceperclass,orpereverytestmethod">Setup CamelContext once per class, or per every test method</h3><p><strong>Available as of Camel 2.8</strong></p><p>The <a shape="rect" href="camel-test.html">Camel Test</a> kit will by default setup and shutdown <a shape="rect" href="camelcontext.html">CamelContext</a> per every test method in your test class. So for example if you have 3 test methods, then <a shape="rect" href="camelcontext.html">CamelContext</a> is started and shutdown after each test, that is 3 times.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">TestNG</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This feature is also supported in camel-testng</p></div></div><div class="confluence-information-macro confluence-information-macro-warning"><p class="title">Beware</p><span class="au i-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using this the <a shape="rect" href="camelcontext.html">CamelContext</a> will keep state between tests, so have that in mind. So if your unit tests start to fail for no apparent reason, it could be due this fact. So use this feature with a bit of care.</p></div></div><p>You may want to do this once, to share the <a shape="rect" href="camelcontext.html">CamelContext</a> between test methods, to speedup unit testing. This requires to use JUnit 4! In your unit test method you have to extend the <code>org.apache.camel.test.junit4.CamelTestSupport</code> or the <code>org.apache.camel.test.junit4.CamelSpringTestSupport</code> test class and override the <code>isCreateCamelContextPerClass</code> method and return <code>true</code> as shown in the following example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHead er pdl" style="border-bottom-width: 1px;"><b>Setup CamelContext once per class</b></div><div class="codeContent panelContent pdl"> +</div></div><h3 id="CamelTest-SetupCamelContextonceperclass,orpereverytestmethod">Setup CamelContext once per class, or per every test method</h3><p><strong>Available as of Camel 2.8</strong></p><p>The <a shape="rect" href="camel-test.html">Camel Test</a> kit will by default setup and shutdown <a shape="rect" href="camelcontext.html">CamelContext</a> per every test method in your test class. So for example if you have 3 test methods, then <a shape="rect" href="camelcontext.html">CamelContext</a> is started and shutdown after each test, that is 3 times.</p><div class="confluence-information-macro confluence-information-macro-tip"><p class="title">TestNG</p><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>This feature is also supported in <strong><code>camel-testng</code></strong></p></div></div><div class="confluence-information-macro confluence-information-macro-warning"><p clas s="title">Beware</p><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>When using this the <a shape="rect" href="camelcontext.html">CamelContext</a> will keep state between tests, so have that in mind. So if your unit tests start to fail for no apparent reason, it could be due this fact. So use this feature with a bit of care.</p></div></div><p>You may want to do this once, to share the <a shape="rect" href="camelcontext.html">CamelContext</a> between test methods, to speedup unit testing. This requires the use of JUnit 4! In your unit test method you have to extend the <strong><code>org.apache.camel.test.junit4.CamelTestSupport</code></strong> or the <strong><code>org.apache.camel.test.junit4.CamelSpringTestSupport</code></strong> test class and override the <strong><code>isCreateCamelContextPerClass</code></strong> method and return <code>true</code> as shown in the following example:< /p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Setup CamelContext once per class</b></div><div class="codeContent panelContent pdl"> <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ public class FilterCreateCamelContextPerClassTest extends CamelTestSupport { @@ -212,10 +215,7 @@ public class FilterCreateCamelContextPer } } ]]></script> -</div></div><h3 id="CamelTest-SeeAlso">See Also</h3><ul><li><a shape="rect" href="testing.html">Testing</a></li><li><a shape="rect" href="mock.html">Mock</a></li><li><a shape="rect" href="test.html">Test</a></li></ul><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[java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory -]]></script> -</div></div></div> +</div></div><h3 id="CamelTest-SeeAlso">See Also</h3><ul><li><a shape="rect" href="testing.html">Testing</a></li><li><a shape="rect" href="mock.html">Mock</a></li><li><a shape="rect" href="test.html">Test</a></li></ul><p> </p></div> </td> <td valign="top"> <div class="navigation">