You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Giorgio Vespucci <gi...@gmail.com> on 2014/10/02 11:34:26 UTC

Re: Migrating from CamelTestSupport to AbstractCamelTestNGSpringContextTests

I posted the question to StackOverflow, too, at
http://stackoverflow.com/questions/26158049/migrating-from-cameltestsupport-to-abstractcameltestngspringcontexttests
.

Thank you all

On Tue, Sep 30, 2014 at 2:32 PM, Giorgio Vespucci <
giorgio.vespucci@gmail.com> wrote:

> Hi everybody
> I've been using Camel since 3-4 months on Spring 4.0.7.RELEASE
> I have several Camel 2.14.0 TestNG tests based on extending
> CamelTestSupport, in which I use some MockEndpoints.
> I configured my routes by overriding the createRouteBuilder() method.
>
> Now I would need also to inject some Spring beans in one of them, by
> @Autowired annotation.
> By reading what is said at http://camel.apache.org/spring-testing.html, I
> understood that I've to extend AbstractCamelTestNGSpringContextTests now,
> which supports @Autowired, @DirtiesContext, and@ContextConfiguration.
>
> While I understood that all MockEndpoints are no more accessible
> by getMockEndpoint() method, but by using @EndpointInject annotation, it
> is not clear to me is how I can express my routes, because createRouteBuilder()
> is not more available.
>
> I saw that is possible to define producers and consumers by using
> annotations, but I cannot manage to understand how routes can be designed.
> Many thanks to the community.
> --
> Giorgio Vespucci
> giorgio [dot] vespucci [at] gmail [dot] com
> Skype, Twitter, Slideshare: gvespucci
> http://xpermanwalking.blogspot.com
>



-- 
Giorgio Vespucci
giorgio [dot] vespucci [at] gmail [dot] com
Skype, Twitter, Slideshare: gvespucci
http://xpermanwalking.blogspot.com

RE: Migrating from CamelTestSupport to AbstractCamelTestNGSpringContextTests

Posted by "Kuhtz, Andreas" <an...@atos.net>.
Hi Giorgio,

The test class:
https://github.com/apache/camel/blob/master/components/camel-testng/src/test/java/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsPlainTest.java

The definition of the camelContext used in the test:
https://github.com/apache/camel/blob/master/components/camel-testng/src/test/resources/org/apache/camel/testng/AbstractCamelTestNGSpringContextTestsPlainTest-context.xml

If you want to define the routes with a routeBuilder then here is an example. The TestRouteBuilder is added because of the " <packageScan>" definition in  AbstractCamelTestNGSpringContextTestsPlainTest-context.xml:
https://github.com/apache/camel/blob/master/components/camel-testng/src/test/java/org/apache/camel/testng/TestRouteBuilder.java

Hope this helps.

-----Original Message-----
From: Giorgio Vespucci [mailto:giorgio.vespucci@gmail.com]
Sent: Thursday, October 02, 2014 11:34 AM
To: Camel Users
Subject: Re: Migrating from CamelTestSupport to AbstractCamelTestNGSpringContextTests

I posted the question to StackOverflow, too, at http://stackoverflow.com/questions/26158049/migrating-from-cameltestsupport-to-abstractcameltestngspringcontexttests
.

Thank you all

On Tue, Sep 30, 2014 at 2:32 PM, Giorgio Vespucci < giorgio.vespucci@gmail.com> wrote:

> Hi everybody
> I've been using Camel since 3-4 months on Spring 4.0.7.RELEASE I have
> several Camel 2.14.0 TestNG tests based on extending CamelTestSupport,
> in which I use some MockEndpoints.
> I configured my routes by overriding the createRouteBuilder() method.
>
> Now I would need also to inject some Spring beans in one of them, by
> @Autowired annotation.
> By reading what is said at
> http://camel.apache.org/spring-testing.html, I understood that I've to
> extend AbstractCamelTestNGSpringContextTests now, which supports @Autowired, @DirtiesContext, and@ContextConfiguration.
>
> While I understood that all MockEndpoints are no more accessible by
> getMockEndpoint() method, but by using @EndpointInject annotation, it
> is not clear to me is how I can express my routes, because
> createRouteBuilder() is not more available.
>
> I saw that is possible to define producers and consumers by using
> annotations, but I cannot manage to understand how routes can be designed.
> Many thanks to the community.
> --
> Giorgio Vespucci
> giorgio [dot] vespucci [at] gmail [dot] com Skype, Twitter,
> Slideshare: gvespucci http://xpermanwalking.blogspot.com
>



--
Giorgio Vespucci
giorgio [dot] vespucci [at] gmail [dot] com Skype, Twitter, Slideshare: gvespucci http://xpermanwalking.blogspot.com
Wichtiger Hinweis: Diese E-Mail kann Betriebs- oder Geschäftsgeheimnisse oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail ausdrücklich untersagt. Bitte benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen Dank.

Important Note: This e-mail may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you have received this e-mail in error, you are hereby notified that any review, copying or distribution of it is strictly prohibited. Please inform us immediately and destroy the original transmittal. Thank you for your cooperation.