camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem jiang <willem.ji...@gmail.com>
Subject Re: Issues with JavaConfigContextLoader
Date Thu, 09 Aug 2012 02:55:53 GMT
Thanks for sharing this with us. 

-- 
Willem Jiang

FuseSource
Web: http://www.fusesource.com (http://www.fusesource.com/)
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang


Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Thursday, August 9, 2012 at 8:11 AM, J. Ecklund wrote:

> Hello,
> 
> While implementing a Camel route in a new project which uses Spring's JavaConfig I ran
into some issues with tests I had written.
> 
> Originally I implemented the tests using the old XML-based appContext, then once I had
everything working I started converting it all to JavaConfig. After some research, I found
that to do this I had to use 
> 
> @ContextConfiguration(
> locations = {"blah.EsbConfig", ... },
> loader = JavaConfigContextLoader.class
> )
> 
> 
> Which was fine, except it completely broke the functionality of the @MockEndpoints annotation
on my tests. I tried adding a org.apache.camel.impl.InterceptSendToMockEndpointStrategy bean
to my JavaConfig context, but that didn't change anything. To fix it I ended up making a new
(Smart)ContextLoader called CamelSpringDelegatingTestContextLoader, which extends Spring's
DelegatingSmartContextLoader and is based on CamelSpringTestContextLoader. It handles both
XML and JavaConfig style Spring configuration, and so far seems to have fixed everything.
You must use CamelSpringJUnit4ClassRunner for this to work, and change @ContextConfiguration's
"locations" to "classes" (and specify them as Class instances). 
> 
> In case it helps anyone in this situation, I am attaching the source.
> 
> Regards,
> 
> -Joshua 



Mime
View raw message