You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by lawrence <la...@pressinnov.com> on 2013/05/14 17:00:16 UTC

CamelContext not loaded during Tests

Hi,
I am kind of new to Camel, and I can't figure out why my camel context is
not loaded when running my tests.
I want to configure my context properly before deep diving into code, and
even with a basic example, and I can't make it.

I'd like to test existing routes (to avoid duplicating routes in code and
tests). I am pretty clear with adviceWith() and weave*(), but when I start
my tests, I have no routes loaded resulting in some NPE when calling
context.getRoutes("xx")
I use some mongoDB bean (but this works fine, no worries on that) that input
5 messages in the route.
I try to weave a mockEndpoint at the end of my route to check that the 5
messages get there.

My guess is that as the camel-context has its own @id, I should load this
particular context, not the default CamelContext, but
1/ if I anonymise the context (get rid of the @id), I still have the same
problem (which makes me say it is not such a good hint...)
2/ I can't find how to grab the named context

Any help appreciated!

Here are my samples:

*src/main/resources/META-INF/spring/application-context.xml*
eholder location="classpath:**.properties"/>
//blabla + some beans

*src/main/resources/META-INF/spring/camel-context.xml*


*src/main/.../testbuilder.java*


*src/test/resources/META-INF/spring/test-application-context.xml*



*src/test/resources/META-INF/spring/test-camel-context.xml*



*src/test/.../TestBuilderTest.java*






--
View this message in context: http://camel.465427.n5.nabble.com/CamelContext-not-loaded-during-Tests-tp5732498.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CamelContext not loaded during Tests

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You should use CamelSpringTestSupport from camel-test-spring to test
spring xml apps.

On Tue, May 14, 2013 at 5:00 PM, lawrence
<la...@pressinnov.com> wrote:
>
> Hi,
> I am kind of new to Camel, and I can't figure out why my camel context is
> not loaded when running my tests.
> I want to configure my context properly before deep diving into code, and
> even with a basic example, and I can't make it.
>
> I'd like to test existing routes (to avoid duplicating routes in code and
> tests). I am pretty clear with adviceWith() and weave*(), but when I start
> my tests, I have no routes loaded resulting in some NPE when calling
> context.getRoutes("xx")
> I use some mongoDB bean (but this works fine, no worries on that) that input
> 5 messages in the route.
> I try to weave a mockEndpoint at the end of my route to check that the 5
> messages get there.
>
> My guess is that as the camel-context has its own @id, I should load this
> particular context, not the default CamelContext, but
> 1/ if I anonymise the context (get rid of the @id), I still have the same
> problem (which makes me say it is not such a good hint...)
> 2/ I can't find how to grab the named context
>
> Any help appreciated!
>
> Here are my samples:
>
> *src/main/resources/META-INF/spring/application-context.xml*
> eholder location="classpath:**.properties"/>
> //blabla + some beans
>
> *src/main/resources/META-INF/spring/camel-context.xml*
>
>
> *src/main/.../testbuilder.java*
>
>
> *src/test/resources/META-INF/spring/test-application-context.xml*
>
>
>
> *src/test/resources/META-INF/spring/test-camel-context.xml*
>
>
>
> *src/test/.../TestBuilderTest.java*
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CamelContext-not-loaded-during-Tests-tp5732498.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen