You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by John <Jo...@ateb.com> on 2010/11/23 16:19:08 UTC

Testing a bean with @Resource

I'm using Camel 2.2.

I have a bean used in a route that is annotated with a couple of @Resource
objects that are injected via Spring. The bean also calls the producer
template to forward requests to different routes.

I've tried to add mocks to the @Resource objects in a spring configuration
file that is referenced via @ContextConfiguration in my test class. This
seems to work ok, but I really want to create the camel route interceptors
to check on what the producer is doing in the bean.

Is there a way to load @Resource classes from the spring configuration file
if I switch to CamelSpringTestSupport using createApplicationContext?

Thanks,

-john


-- 
View this message in context: http://camel.465427.n5.nabble.com/Testing-a-bean-with-Resource-tp3276944p3276944.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing a bean with @Resource

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

Can you try with Camel 2.5.

And you are welcome to put together a little ZIP file with your
project so others can take a look.

On Sat, Nov 27, 2010 at 8:12 PM, John <Jo...@ateb.com> wrote:
>
> I have tried switching to CamelSpringTestSupport. What I found was that
> loading the application context via createApplicationContext did not inject
> the mocks I defined in my spring xml in the test class. I've only managed to
> get them loaded by using the normal spring @ContextConfiguration.
>
> Thanks,
>
> -john
> --
> View this message in context: http://camel.465427.n5.nabble.com/Testing-a-bean-with-Resource-tp3276944p3282618.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
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/

Re: Testing a bean with @Resource

Posted by John <Jo...@ateb.com>.
I have tried switching to CamelSpringTestSupport. What I found was that
loading the application context via createApplicationContext did not inject
the mocks I defined in my spring xml in the test class. I've only managed to
get them loaded by using the normal spring @ContextConfiguration.

Thanks,

-john
-- 
View this message in context: http://camel.465427.n5.nabble.com/Testing-a-bean-with-Resource-tp3276944p3282618.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing a bean with @Resource

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Nov 23, 2010 at 4:19 PM, John <Jo...@ateb.com> wrote:
>
> I'm using Camel 2.2.
>
> I have a bean used in a route that is annotated with a couple of @Resource
> objects that are injected via Spring. The bean also calls the producer
> template to forward requests to different routes.
>
> I've tried to add mocks to the @Resource objects in a spring configuration
> file that is referenced via @ContextConfiguration in my test class. This
> seems to work ok, but I really want to create the camel route interceptors
> to check on what the producer is doing in the bean.
>
> Is there a way to load @Resource classes from the spring configuration file
> if I switch to CamelSpringTestSupport using createApplicationContext?
>

Have you tried switching to CamelSpringTestSupport?

> Thanks,
>
> -john
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Testing-a-bean-with-Resource-tp3276944p3276944.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
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/