Author: buildbot
Date: Sun Jul 1 08:18:08 2012
New Revision: 823915
Log:
Production update by buildbot for camel
Modified:
websites/production/camel/content/advicewith.html
websites/production/camel/content/cache/main.pageCache
Modified: websites/production/camel/content/advicewith.html
==============================================================================
--- websites/production/camel/content/advicewith.html (original)
+++ websites/production/camel/content/advicewith.html Sun Jul 1 08:18:08 2012
@@ -353,7 +353,52 @@ context.getRouteDefinitions().get(0).adv
<p><b>Available as of Camel 2.9</b><br clear="none">
It is recommended to override the method <tt>isUseAdviceWith</tt> and return
<tt>true</tt> to instruct Camel that you are using <tt>adviceWith</tt> in the
unit tests. Then in your unit test methods, after you have done the
<tt>adviceWith</tt> you <b>must</b> start <tt>CamelContext</tt> by invoke the
<tt>start</tt> method on the <tt>context</tt> instance. In the following we
have an example. The route is using <a shape="rect" href="activemq.html"
title="ActiveMQ">ActiveMQ</a> to route messages. What we would like to do in a
unit test is to test the route, but without having to set and use <a
shape="rect" href="activemq.html" title="ActiveMQ">ActiveMQ</a>. We do not have
<a shape="rect" href="activemq.html" title="ActiveMQ">ActiveMQ</a> on the
classpath. So for that we need to advice the route and replace <a shape="rect"
href="activemq.html" title="ActiveMQ">ActiveMQ</a> with for example a <a
shape="rect" href="seda.html" title="SEDA">SEDA</a> endpoint instead. </p>
-<div class="error"><span class="error">Error formatting macro: snippet:
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </div></div>
+<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>isUseAdviceWith</b></div><div
class="codeContent panelContent">
+<pre class="code-java"><span class="code-keyword">public</span> class
IsUseAdviceWithJUnit4Test <span class="code-keyword">extends</span>
org.apache.camel.test.junit4.CamelTestSupport {
+
+ @Test
+ <span class="code-keyword">public</span> void testIsUseAdviceWith() <span
class="code-keyword">throws</span> Exception {
+ context.getRouteDefinitions().get(0).adviceWith(context, <span
class="code-keyword">new</span> AdviceWithRouteBuilder() {
+ @Override
+ <span class="code-keyword">public</span> void configure() <span
class="code-keyword">throws</span> Exception {
+ <span class="code-comment">// replace the from with seda:foo
+</span> replaceFromWith(<span
class="code-quote">"seda:foo"</span>);
+ }
+ });
+ <span class="code-comment">// we must manually start when we are done
with all the advice with
+</span> context.start();
+
+ getMockEndpoint(<span
class="code-quote">"mock:result"</span>).expectedMessageCount(1);
+
+ template.sendBody(<span class="code-quote">"seda:foo"</span>, <span
class="code-quote">"Hello World"</span>);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ <span class="code-keyword">public</span> <span
class="code-object">boolean</span> isUseAdviceWith() {
+ <span class="code-comment">// tell we are using advice with, which
allows us to advice the route
+</span> <span class="code-comment">// before Camel is being started,
and thus can replace activemq with something <span
class="code-keyword">else</span>.
+</span> <span class="code-keyword">return</span> <span
class="code-keyword">true</span>;
+ }
+
+ <span class="code-comment">// This is the route we want to test
+</span> @Override
+ <span class="code-keyword">protected</span> RouteBuilder
createRouteBuilder() <span class="code-keyword">throws</span> Exception {
+ <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 {
+ <span class="code-comment">// we <span
class="code-keyword">do</span> not have activemq on the classpath
+</span> <span class="code-comment">// but the route has it
included
+</span> from(<span
class="code-quote">"activemq:queue:foo"</span>)
+ .to(<span class="code-quote">"mock:result"</span>);
+ }
+ };
+ }
+
+}
+</pre>
+</div></div></div>
</td>
<td valign="top">
<div class="navigation">
Modified: websites/production/camel/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.