Modified: websites/production/camel/content/testing.html
==============================================================================
--- websites/production/camel/content/testing.html (original)
+++ websites/production/camel/content/testing.html Thu Jan 31 18:21:49 2013
@@ -145,7 +145,7 @@
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
<pre class="code-java">@ContextConfiguration
-<span class="code-keyword">public</span> class FilterTest <span
class="code-keyword">extends</span> AbstractJUnit38SpringContextTests {
+<span class="code-keyword">public</span> class FilterTest <span
class="code-keyword">extends</span> SpringRunWithTestSupport {
@EndpointInject(uri = <span class="code-quote">"mock:result"</span>)
<span class="code-keyword">protected</span> MockEndpoint resultEndpoint;
@@ -154,6 +154,7 @@
<span class="code-keyword">protected</span> ProducerTemplate template;
@DirtiesContext
+ @Test
<span class="code-keyword">public</span> void testSendMatchingMessage()
<span class="code-keyword">throws</span> Exception {
<span class="code-object">String</span> expectedBody = <span
class="code-quote">"<matched/>"</span>;
@@ -165,6 +166,7 @@
}
@DirtiesContext
+ @Test
<span class="code-keyword">public</span> void testSendNotMatchingMessage()
<span class="code-keyword">throws</span> Exception {
resultEndpoint.expectedMessageCount(0);
@@ -264,90 +266,7 @@
<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>
-<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>
+<div class="error"><span class="error">Error formatting macro: snippet:
java.lang.IndexOutOfBoundsException: Index: 20, Size: 20</span> </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>