On Mon, Nov 1, 2010 at 9:44 PM, Mark Webb <[email protected]> wrote:
> Figured it out using the page http://camel.apache.org/testing.html and
> section Spring Test with XML Config Example.
>

The Camel in Action book covers testing in chapter 6 which is a full
chapter devoted to testing with Camel.


>
> On Mon, Nov 1, 2010 at 4:16 PM, Mark Webb <[email protected]> wrote:
>> I have a route defined in XML that I want to unit test.  Is there a
>> way to do this?  I have found CamelSpringTestSupport, but I am not
>> sure that is what I want.  When I run a unit test that extends
>> CamelSpringTestSupport I get the following stack trace.
>>
>> org.apache.camel.CamelExecutionException: Exception occurred during
>> execution on the exchange: Exchange[Message: HELLO WORLD]
>>        at 
>> org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1156)
>>        at 
>> org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:456)
>>        at 
>> org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:441)
>>        at 
>> org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:437)
>>        at 
>> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:125)
>>        at 
>> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:341)
>>        at com.x.y.z.RecipientXmlTest.testTest(RecipientXmlTest.java:33)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>        at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at junit.framework.TestCase.runTest(TestCase.java:168)
>>        at junit.framework.TestCase.runBare(TestCase.java:134)
>>        at org.apache.camel.test.TestSupport.runBare(TestSupport.java:65)
>>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>>        at junit.framework.TestResult.run(TestResult.java:113)
>>        at junit.framework.TestCase.run(TestCase.java:124)
>>        at junit.framework.TestSuite.runTest(TestSuite.java:243)
>>        at junit.framework.TestSuite.run(TestSuite.java:238)
>>        at 
>> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
>>        at 
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
>>        at 
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>        at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>        at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>        at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>        at 
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>> Caused by: org.apache.camel.CamelExchangeException: No consumers
>> available on endpoint: Endpoint[direct://start]. Exchange[Message:
>> HELLO WORLD]
>>        at 
>> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:56)
>>        at 
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:99)
>>        at 
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:91)
>>        at 
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)
>>        at 
>> org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
>>        at 
>> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:333)
>>        at 
>> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:303)
>>        at 
>> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:208)
>>        at 
>> org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:303)
>>        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:154)
>>        at 
>> org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:110)
>>        at 
>> org.apache.camel.impl.DefaultProducerTemplate.sendBody(DefaultProducerTemplate.java:123)
>>        ... 22 more
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Reply via email to