Author: buildbot
Date: Thu Mar 14 14:22:30 2013
New Revision: 854441
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/book-cookbook.html
websites/production/camel/content/book-in-one-page.html
websites/production/camel/content/cache/main.pageCache
websites/production/camel/content/spring-java-config.html
websites/production/camel/content/testing.html
Modified: websites/production/camel/content/book-cookbook.html
==============================================================================
--- websites/production/camel/content/book-cookbook.html (original)
+++ websites/production/camel/content/book-cookbook.html Thu Mar 14 14:22:30
2013
@@ -1752,7 +1752,9 @@ mock.allMessages().arrives().noLaterThan
<h4><a shape="rect"
name="Bookcookbook-SpringTestwithJavaConfigExample"></a>Spring Test with Java
Config Example</h4>
-<p>Here is the <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">example
using Java Config</a>. For more information see <a shape="rect"
href="spring-java-config.html" title="Spring Java Config">Spring Java
Config</a>.</p>
+<p>Here is the <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">example
using Java Config</a>. </p>
+
+<p>For more information see <a shape="rect" href="spring-java-config.html"
title="Spring Java Config">Spring Java Config</a>.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">@ContextConfiguration(
@@ -1807,11 +1809,145 @@ mock.allMessages().arrives().noLaterThan
<p>Its totally optional but for the ContextConfig implementation we derive
from <b>SingleRouteCamelConfiguration</b> which is a helper Spring Java Config
class which will configure the CamelContext for us and then register the
RouteBuilder we create.</p>
+<p>Since <b>Camel 2.11.0</b> you can use the CamelSpringJUnit4ClassRunner with
CamelSpringDelegatingTestContextLoader 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 CamelSpringJUnit4ClassRunner</a>.<br clear="none">
+</p><div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration(
+ classes =
{CamelSpringDelegatingTestContextLoaderTest.TestConfig.class},
+ <span class="code-comment">// Since Camel 2.11.0
+</span> loader = CamelSpringDelegatingTestContextLoader.class
+)
+@MockEndpoints
+<span class="code-keyword">public</span> class
CamelSpringDelegatingTestContextLoaderTest {
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:end"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint endEndpoint;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:error"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint errorEndpoint;
+
+ @Produce(uri = <span class="code-quote">"direct:test"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate testProducer;
+
+ @Configuration
+ <span class="code-keyword">public</span> <span
class="code-keyword">static</span> class TestConfig <span
class="code-keyword">extends</span> SingleRouteCamelConfiguration {
+ @Bean
+ @Override
+ <span class="code-keyword">public</span> RouteBuilder route() {
+ <span class="code-keyword">return</span> <span
class="code-keyword">new</span> RouteBuilder() {
+ @Override
+ <span class="code-keyword">public</span> void configure()
<span class="code-keyword">throws</span> Exception {
+ from(<span
class="code-quote">"direct:test"</span>).errorHandler(deadLetterChannel(<span
class="code-quote">"direct:error"</span>)).to(<span
class="code-quote">"direct:end"</span>);
+
+ from(<span
class="code-quote">"direct:error"</span>).log(<span
class="code-quote">"Received message on direct:error endpoint."</span>);
+
+ from(<span
class="code-quote">"direct:end"</span>).log(<span class="code-quote">"Received
message on direct:end endpoint."</span>);
+ }
+ };
+ }
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testRoute() <span
class="code-keyword">throws</span> InterruptedException {
+ endEndpoint.expectedMessageCount(1);
+ errorEndpoint.expectedMessageCount(0);
+
+ testProducer.sendBody(<span
class="code-quote">"<name>test</name>"</span>);
+
+ endEndpoint.assertIsSatisfied();
+ errorEndpoint.assertIsSatisfied();
+ }
+}
+</pre>
+</div></div>.
+
<h4><a shape="rect"
name="Bookcookbook-SpringTestwithXMLConfigandDeclarativeConfigurationExample"></a>Spring
Test with XML Config and Declarative Configuration Example</h4>
-<p>Here is a Camel test support enhanced <a shape="rect"
href="spring-testing.html" title="Spring Testing">Spring Testing</a> <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/junit4/CamelSpringJUnit4ClassRunnerPlainTest.java">example
using XML Config and pure Spring Test based configuration of the Camel
Context</a>.</p>
+<p>Here is a Camel test support enhanced <a shape="rect"
href="spring-testing.html" title="Spring Testing">Spring Testing</a> <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>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration
+<span class="code-comment">// Put here to prevent Spring context caching
across tests and test methods since some tests inherit
+</span><span class="code-comment">// from <span
class="code-keyword">this</span> test and therefore use the same Spring
context. Also because we want to reset the
+</span><span class="code-comment">// Camel context and mock endpoints between
test methods automatically.
+</span>@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+<span class="code-keyword">public</span> class
CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Autowired
+ <span class="code-keyword">protected</span> CamelContext camelContext;
+
+ @Autowired
+ <span class="code-keyword">protected</span> CamelContext camelContext2;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:a"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockA;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:b"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockB;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:c"</span>, context =
<span class="code-quote">"camelContext2"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockC;
+
+ @Produce(uri = <span class="code-quote">"direct:start"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate start;
+
+ @Produce(uri = <span class="code-quote">"direct:start2"</span>, context =
<span class="code-quote">"camelContext2"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate start2;
+
+ @Test
+ <span class="code-keyword">public</span> void testPositive() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(ServiceStatus.Started, camelContext.getStatus());
+ assertEquals(ServiceStatus.Started, camelContext2.getStatus());
+
+ mockA.expectedBodiesReceived(<span class="code-quote">"David"</span>);
+ mockB.expectedBodiesReceived(<span class="code-quote">"Hello
David"</span>);
+ mockC.expectedBodiesReceived(<span class="code-quote">"David"</span>);
+
+ start.sendBody(<span class="code-quote">"David"</span>);
+ start2.sendBody(<span class="code-quote">"David"</span>);
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testJmx() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(DefaultManagementStrategy.class,
camelContext.getManagementStrategy().getClass());
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testShutdownTimeout() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(10, camelContext.getShutdownStrategy().getTimeout());
+ assertEquals(TimeUnit.SECONDS,
camelContext.getShutdownStrategy().getTimeUnit());
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testStopwatch() {
+ StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
+
+ assertNotNull(stopWatch);
+ assertTrue(stopWatch.taken() < 100);
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testExcludedRoute() {
+ assertNotNull(camelContext.getRoute(<span
class="code-quote">"excludedRoute"</span>));
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testProvidesBreakpoint() {
+ assertNull(camelContext.getDebugger());
+ assertNull(camelContext2.getDebugger());
+ }
+
+ @SuppressWarnings(<span class="code-quote">"deprecation"</span>)
+ @Test
+ <span class="code-keyword">public</span> void testLazyLoadTypeConverters()
{
+ assertTrue(camelContext.isLazyLoadTypeConverters());
+ assertTrue(camelContext2.isLazyLoadTypeConverters());
+ }
+}
+</pre>
+</div></div>
<p>Notice how a custom test runner is used with
the <b>@RunWith</b> annotation to support the features
of <b>CamelTestSupport</b> through annotations on the test class.
 See <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> for a list of annotations you can use in your
tests.</p>
Modified: websites/production/camel/content/book-in-one-page.html
==============================================================================
--- websites/production/camel/content/book-in-one-page.html (original)
+++ websites/production/camel/content/book-in-one-page.html Thu Mar 14 14:22:30
2013
@@ -2973,7 +2973,9 @@ mock.allMessages().arrives().noLaterThan
<h4><a shape="rect"
name="BookInOnePage-SpringTestwithJavaConfigExample"></a>Spring Test with Java
Config Example</h4>
-<p>Here is the <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">example
using Java Config</a>. For more information see <a shape="rect"
href="spring-java-config.html" title="Spring Java Config">Spring Java
Config</a>.</p>
+<p>Here is the <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">example
using Java Config</a>. </p>
+
+<p>For more information see <a shape="rect" href="spring-java-config.html"
title="Spring Java Config">Spring Java Config</a>.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">@ContextConfiguration(
@@ -3028,11 +3030,145 @@ mock.allMessages().arrives().noLaterThan
<p>Its totally optional but for the ContextConfig implementation we derive
from <b>SingleRouteCamelConfiguration</b> which is a helper Spring Java Config
class which will configure the CamelContext for us and then register the
RouteBuilder we create.</p>
+<p>Since <b>Camel 2.11.0</b> you can use the CamelSpringJUnit4ClassRunner with
CamelSpringDelegatingTestContextLoader 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 CamelSpringJUnit4ClassRunner</a>.<br clear="none">
+</p><div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration(
+ classes =
{CamelSpringDelegatingTestContextLoaderTest.TestConfig.class},
+ <span class="code-comment">// Since Camel 2.11.0
+</span> loader = CamelSpringDelegatingTestContextLoader.class
+)
+@MockEndpoints
+<span class="code-keyword">public</span> class
CamelSpringDelegatingTestContextLoaderTest {
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:end"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint endEndpoint;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:error"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint errorEndpoint;
+
+ @Produce(uri = <span class="code-quote">"direct:test"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate testProducer;
+
+ @Configuration
+ <span class="code-keyword">public</span> <span
class="code-keyword">static</span> class TestConfig <span
class="code-keyword">extends</span> SingleRouteCamelConfiguration {
+ @Bean
+ @Override
+ <span class="code-keyword">public</span> RouteBuilder route() {
+ <span class="code-keyword">return</span> <span
class="code-keyword">new</span> RouteBuilder() {
+ @Override
+ <span class="code-keyword">public</span> void configure()
<span class="code-keyword">throws</span> Exception {
+ from(<span
class="code-quote">"direct:test"</span>).errorHandler(deadLetterChannel(<span
class="code-quote">"direct:error"</span>)).to(<span
class="code-quote">"direct:end"</span>);
+
+ from(<span
class="code-quote">"direct:error"</span>).log(<span
class="code-quote">"Received message on direct:error endpoint."</span>);
+
+ from(<span
class="code-quote">"direct:end"</span>).log(<span class="code-quote">"Received
message on direct:end endpoint."</span>);
+ }
+ };
+ }
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testRoute() <span
class="code-keyword">throws</span> InterruptedException {
+ endEndpoint.expectedMessageCount(1);
+ errorEndpoint.expectedMessageCount(0);
+
+ testProducer.sendBody(<span
class="code-quote">"<name>test</name>"</span>);
+
+ endEndpoint.assertIsSatisfied();
+ errorEndpoint.assertIsSatisfied();
+ }
+}
+</pre>
+</div></div>.
+
<h4><a shape="rect"
name="BookInOnePage-SpringTestwithXMLConfigandDeclarativeConfigurationExample"></a>Spring
Test with XML Config and Declarative Configuration Example</h4>
-<p>Here is a Camel test support enhanced <a shape="rect"
href="spring-testing.html" title="Spring Testing">Spring Testing</a> <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/junit4/CamelSpringJUnit4ClassRunnerPlainTest.java">example
using XML Config and pure Spring Test based configuration of the Camel
Context</a>.</p>
+<p>Here is a Camel test support enhanced <a shape="rect"
href="spring-testing.html" title="Spring Testing">Spring Testing</a> <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>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration
+<span class="code-comment">// Put here to prevent Spring context caching
across tests and test methods since some tests inherit
+</span><span class="code-comment">// from <span
class="code-keyword">this</span> test and therefore use the same Spring
context. Also because we want to reset the
+</span><span class="code-comment">// Camel context and mock endpoints between
test methods automatically.
+</span>@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+<span class="code-keyword">public</span> class
CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Autowired
+ <span class="code-keyword">protected</span> CamelContext camelContext;
+
+ @Autowired
+ <span class="code-keyword">protected</span> CamelContext camelContext2;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:a"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockA;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:b"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockB;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:c"</span>, context =
<span class="code-quote">"camelContext2"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockC;
+
+ @Produce(uri = <span class="code-quote">"direct:start"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate start;
+
+ @Produce(uri = <span class="code-quote">"direct:start2"</span>, context =
<span class="code-quote">"camelContext2"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate start2;
+
+ @Test
+ <span class="code-keyword">public</span> void testPositive() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(ServiceStatus.Started, camelContext.getStatus());
+ assertEquals(ServiceStatus.Started, camelContext2.getStatus());
+
+ mockA.expectedBodiesReceived(<span class="code-quote">"David"</span>);
+ mockB.expectedBodiesReceived(<span class="code-quote">"Hello
David"</span>);
+ mockC.expectedBodiesReceived(<span class="code-quote">"David"</span>);
+
+ start.sendBody(<span class="code-quote">"David"</span>);
+ start2.sendBody(<span class="code-quote">"David"</span>);
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testJmx() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(DefaultManagementStrategy.class,
camelContext.getManagementStrategy().getClass());
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testShutdownTimeout() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(10, camelContext.getShutdownStrategy().getTimeout());
+ assertEquals(TimeUnit.SECONDS,
camelContext.getShutdownStrategy().getTimeUnit());
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testStopwatch() {
+ StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
+
+ assertNotNull(stopWatch);
+ assertTrue(stopWatch.taken() < 100);
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testExcludedRoute() {
+ assertNotNull(camelContext.getRoute(<span
class="code-quote">"excludedRoute"</span>));
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testProvidesBreakpoint() {
+ assertNull(camelContext.getDebugger());
+ assertNull(camelContext2.getDebugger());
+ }
+
+ @SuppressWarnings(<span class="code-quote">"deprecation"</span>)
+ @Test
+ <span class="code-keyword">public</span> void testLazyLoadTypeConverters()
{
+ assertTrue(camelContext.isLazyLoadTypeConverters());
+ assertTrue(camelContext2.isLazyLoadTypeConverters());
+ }
+}
+</pre>
+</div></div>
<p>Notice how a custom test runner is used with
the <b>@RunWith</b> annotation to support the features
of <b>CamelTestSupport</b> through annotations on the test class.
 See <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> for a list of annotations you can use in your
tests.</p>
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/camel/content/spring-java-config.html
==============================================================================
--- websites/production/camel/content/spring-java-config.html (original)
+++ websites/production/camel/content/spring-java-config.html Thu Mar 14
14:22:30 2013
@@ -156,7 +156,58 @@
<p>The <b>@ContextConfiguration</b> annotation tells the <a shape="rect"
href="spring-testing.html" title="Spring Testing">Spring Testing</a> framework
to load the <b>ContextConfig</b> class as the configuration to use. This class
derives from <b>SingleRouteCamelConfiguration</b> which is a helper Spring Java
Config class which will configure the CamelContext for us and then register the
RouteBuilder we create.</p>
-<p>If you wish to create a collection of <b>RouteBuilder</b> instances then
derive from the <b>CamelConfiguration</b> helper class and implement the
<b>routes()</b> method.</p></div>
+<p>If you wish to create a collection of <b>RouteBuilder</b> instances then
derive from the <b>CamelConfiguration</b> helper class and implement the
<b>routes()</b> method.</p>
+
+<p>Since <b>Camel 2.11.0</b> you can use the CamelSpringJUnit4ClassRunner with
CamelSpringDelegatingTestContextLoader 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 CamelSpringJUnit4ClassRunner</a>.<br clear="none">
+</p><div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration(
+ classes =
{CamelSpringDelegatingTestContextLoaderTest.TestConfig.class},
+ <span class="code-comment">// Since Camel 2.11.0
+</span> loader = CamelSpringDelegatingTestContextLoader.class
+)
+@MockEndpoints
+<span class="code-keyword">public</span> class
CamelSpringDelegatingTestContextLoaderTest {
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:end"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint endEndpoint;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:error"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint errorEndpoint;
+
+ @Produce(uri = <span class="code-quote">"direct:test"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate testProducer;
+
+ @Configuration
+ <span class="code-keyword">public</span> <span
class="code-keyword">static</span> class TestConfig <span
class="code-keyword">extends</span> SingleRouteCamelConfiguration {
+ @Bean
+ @Override
+ <span class="code-keyword">public</span> RouteBuilder route() {
+ <span class="code-keyword">return</span> <span
class="code-keyword">new</span> RouteBuilder() {
+ @Override
+ <span class="code-keyword">public</span> void configure()
<span class="code-keyword">throws</span> Exception {
+ from(<span
class="code-quote">"direct:test"</span>).errorHandler(deadLetterChannel(<span
class="code-quote">"direct:error"</span>)).to(<span
class="code-quote">"direct:end"</span>);
+
+ from(<span
class="code-quote">"direct:error"</span>).log(<span
class="code-quote">"Received message on direct:error endpoint."</span>);
+
+ from(<span
class="code-quote">"direct:end"</span>).log(<span class="code-quote">"Received
message on direct:end endpoint."</span>);
+ }
+ };
+ }
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testRoute() <span
class="code-keyword">throws</span> InterruptedException {
+ endEndpoint.expectedMessageCount(1);
+ errorEndpoint.expectedMessageCount(0);
+
+ testProducer.sendBody(<span
class="code-quote">"<name>test</name>"</span>);
+
+ endEndpoint.assertIsSatisfied();
+ errorEndpoint.assertIsSatisfied();
+ }
+}
+</pre>
+</div></div>.</div>
</td>
<td valign="top">
<div class="navigation">
Modified: websites/production/camel/content/testing.html
==============================================================================
--- websites/production/camel/content/testing.html (original)
+++ websites/production/camel/content/testing.html Thu Mar 14 14:22:30 2013
@@ -207,7 +207,9 @@
<h4><a shape="rect" name="Testing-SpringTestwithJavaConfigExample"></a>Spring
Test with Java Config Example</h4>
-<p>Here is the <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">example
using Java Config</a>. For more information see <a shape="rect"
href="spring-java-config.html" title="Spring Java Config">Spring Java
Config</a>.</p>
+<p>Here is the <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/camel/trunk/components/camel-spring-javaconfig/src/test/java/org/apache/camel/spring/javaconfig/patterns/FilterTest.java">example
using Java Config</a>. </p>
+
+<p>For more information see <a shape="rect" href="spring-java-config.html"
title="Spring Java Config">Spring Java Config</a>.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">@ContextConfiguration(
@@ -262,11 +264,145 @@
<p>Its totally optional but for the ContextConfig implementation we derive
from <b>SingleRouteCamelConfiguration</b> which is a helper Spring Java Config
class which will configure the CamelContext for us and then register the
RouteBuilder we create.</p>
+<p>Since <b>Camel 2.11.0</b> you can use the CamelSpringJUnit4ClassRunner with
CamelSpringDelegatingTestContextLoader 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 CamelSpringJUnit4ClassRunner</a>.<br clear="none">
+</p><div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration(
+ classes =
{CamelSpringDelegatingTestContextLoaderTest.TestConfig.class},
+ <span class="code-comment">// Since Camel 2.11.0
+</span> loader = CamelSpringDelegatingTestContextLoader.class
+)
+@MockEndpoints
+<span class="code-keyword">public</span> class
CamelSpringDelegatingTestContextLoaderTest {
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:end"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint endEndpoint;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:direct:error"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint errorEndpoint;
+
+ @Produce(uri = <span class="code-quote">"direct:test"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate testProducer;
+
+ @Configuration
+ <span class="code-keyword">public</span> <span
class="code-keyword">static</span> class TestConfig <span
class="code-keyword">extends</span> SingleRouteCamelConfiguration {
+ @Bean
+ @Override
+ <span class="code-keyword">public</span> RouteBuilder route() {
+ <span class="code-keyword">return</span> <span
class="code-keyword">new</span> RouteBuilder() {
+ @Override
+ <span class="code-keyword">public</span> void configure()
<span class="code-keyword">throws</span> Exception {
+ from(<span
class="code-quote">"direct:test"</span>).errorHandler(deadLetterChannel(<span
class="code-quote">"direct:error"</span>)).to(<span
class="code-quote">"direct:end"</span>);
+
+ from(<span
class="code-quote">"direct:error"</span>).log(<span
class="code-quote">"Received message on direct:error endpoint."</span>);
+
+ from(<span
class="code-quote">"direct:end"</span>).log(<span class="code-quote">"Received
message on direct:end endpoint."</span>);
+ }
+ };
+ }
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testRoute() <span
class="code-keyword">throws</span> InterruptedException {
+ endEndpoint.expectedMessageCount(1);
+ errorEndpoint.expectedMessageCount(0);
+
+ testProducer.sendBody(<span
class="code-quote">"<name>test</name>"</span>);
+
+ endEndpoint.assertIsSatisfied();
+ errorEndpoint.assertIsSatisfied();
+ }
+}
+</pre>
+</div></div>.
+
<h4><a shape="rect"
name="Testing-SpringTestwithXMLConfigandDeclarativeConfigurationExample"></a>Spring
Test with XML Config and Declarative Configuration Example</h4>
-<p>Here is a Camel test support enhanced <a shape="rect"
href="spring-testing.html" title="Spring Testing">Spring Testing</a> <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/junit4/CamelSpringJUnit4ClassRunnerPlainTest.java">example
using XML Config and pure Spring Test based configuration of the Camel
Context</a>.</p>
+<p>Here is a Camel test support enhanced <a shape="rect"
href="spring-testing.html" title="Spring Testing">Spring Testing</a> <a
shape="rect" class="external-link"
href="https://svn.apache.org/repos/asf/camel/trunk/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest.java">example
using XML Config and pure Spring Test based configuration of the Camel
Context</a>.</p>
+
+<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
+<pre class="code-java">@RunWith(CamelSpringJUnit4ClassRunner.class)
+@ContextConfiguration
+<span class="code-comment">// Put here to prevent Spring context caching
across tests and test methods since some tests inherit
+</span><span class="code-comment">// from <span
class="code-keyword">this</span> test and therefore use the same Spring
context. Also because we want to reset the
+</span><span class="code-comment">// Camel context and mock endpoints between
test methods automatically.
+</span>@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD)
+<span class="code-keyword">public</span> class
CamelSpringJUnit4ClassRunnerPlainTest {
+
+ @Autowired
+ <span class="code-keyword">protected</span> CamelContext camelContext;
+
+ @Autowired
+ <span class="code-keyword">protected</span> CamelContext camelContext2;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:a"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockA;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:b"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockB;
+
+ @EndpointInject(uri = <span class="code-quote">"mock:c"</span>, context =
<span class="code-quote">"camelContext2"</span>)
+ <span class="code-keyword">protected</span> MockEndpoint mockC;
+
+ @Produce(uri = <span class="code-quote">"direct:start"</span>, context =
<span class="code-quote">"camelContext"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate start;
+
+ @Produce(uri = <span class="code-quote">"direct:start2"</span>, context =
<span class="code-quote">"camelContext2"</span>)
+ <span class="code-keyword">protected</span> ProducerTemplate start2;
+
+ @Test
+ <span class="code-keyword">public</span> void testPositive() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(ServiceStatus.Started, camelContext.getStatus());
+ assertEquals(ServiceStatus.Started, camelContext2.getStatus());
+
+ mockA.expectedBodiesReceived(<span class="code-quote">"David"</span>);
+ mockB.expectedBodiesReceived(<span class="code-quote">"Hello
David"</span>);
+ mockC.expectedBodiesReceived(<span class="code-quote">"David"</span>);
+
+ start.sendBody(<span class="code-quote">"David"</span>);
+ start2.sendBody(<span class="code-quote">"David"</span>);
+
+ MockEndpoint.assertIsSatisfied(camelContext);
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testJmx() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(DefaultManagementStrategy.class,
camelContext.getManagementStrategy().getClass());
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testShutdownTimeout() <span
class="code-keyword">throws</span> Exception {
+ assertEquals(10, camelContext.getShutdownStrategy().getTimeout());
+ assertEquals(TimeUnit.SECONDS,
camelContext.getShutdownStrategy().getTimeUnit());
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testStopwatch() {
+ StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch();
+
+ assertNotNull(stopWatch);
+ assertTrue(stopWatch.taken() < 100);
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testExcludedRoute() {
+ assertNotNull(camelContext.getRoute(<span
class="code-quote">"excludedRoute"</span>));
+ }
+
+ @Test
+ <span class="code-keyword">public</span> void testProvidesBreakpoint() {
+ assertNull(camelContext.getDebugger());
+ assertNull(camelContext2.getDebugger());
+ }
-<div class="error"><span class="error">Error formatting macro: snippet:
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div>
+ @SuppressWarnings(<span class="code-quote">"deprecation"</span>)
+ @Test
+ <span class="code-keyword">public</span> void testLazyLoadTypeConverters()
{
+ assertTrue(camelContext.isLazyLoadTypeConverters());
+ assertTrue(camelContext2.isLazyLoadTypeConverters());
+ }
+}
+</pre>
+</div></div>
<p>Notice how a custom test runner is used with
the <b>@RunWith</b> annotation to support the features
of <b>CamelTestSupport</b> through annotations on the test class.
 See <a shape="rect" href="spring-testing.html" title="Spring
Testing">Spring Testing</a> for a list of annotations you can use in your
tests.</p>