camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Problems testing Camel with Spring config
Date Mon, 28 Mar 2011 15:37:18 GMT
On Mon, Mar 28, 2011 at 5:34 PM, Tom Howe <tomhowe@artcore.com> wrote:
> I've read the testing page but it doesnt give any good eaxmple of using
> spring xml routes
>

There is more here
http://camel.apache.org/spring-testing.html


> Can you point me to an example of CamelSpringTestSupport ? I cant see any
> docs on it's usage?
>

Just try to extend this class and it forces you to implement a method
where you load the Spring XML file.
There are many examples in the source code, eg in camel-spring module.
https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/


Btw the Camel in Action book chapter 6 covers all about testing.




> Thanks, Tom
>
> On Mon, Mar 28, 2011 at 4:27 PM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
>
>> Hi
>>
>> Check out this page
>> http://camel.apache.org/testing
>>
>> You can then use any IoC means to inject the mocks, such as
>> @EndpointInjected or any of the Spring or the new @Resource from JDK6
>> etc.
>>
>> Also you can extend CamelSpringTestSupport which allows you to load a
>> Spring XML file.
>> Thats often what we do to test Camel as CamelXXTestSupport is easy to
>> get mocks, producer template and whatnot without having to IoC them.
>>
>>
>> On Mon, Mar 28, 2011 at 5:11 PM, Tom Howe <tomhowe@artcore.com> wrote:
>> > I have a routes defined in CamelRoutes.xml and I would like to test them
>> by
>> > using the wrapping technique described at the bottom of
>> > http://camel.apache.org/mock.html.
>> >
>> > My CamelRoutes.xml
>> >     <route autoStartup="true"  xmlns="
>> http://camel.apache.org/schema/spring
>> > ">
>> >            <from uri="direct:start"/>
>> >            <to uri="direct:end"/>
>> >        </route>
>> >
>> > So I created CamelRoutesTest.xml containing:
>> >
>> >    <import resource="CamelRoutes.xml"/>
>> >    <bean id="mockAllEndpoints"
>> > class="org.apache.camel.impl.InterceptSendToMockEndpointStrategy"/>
>> >
>> > but I am not sure how to create a test that both loads the spring xml AND
>> > provides access to the mock endpoints.
>> >
>> > If I use..
>> >
>> > @ContextConfiguration( locations=("/CamelRoutesTest"))
>> > public class CamelTest extends AbstractJUnit38SpringContextTests
>> >
>> > }
>> >
>> > then I have no idea how to *get* the mock endpoints
>> >
>> > If I use..
>> >
>> > public class CamelTest extends CamelTestSupport
>> >
>> > }
>> >
>> > then I dont know how to load my camel context..
>> >
>> >
>> > I can't seem to find an example test on the website that uses
>> > CamelTestSupport AND loads routes from spring xml.
>> >
>> > thanks, Tom
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>



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

Mime
View raw message