You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jihedamine <ji...@gmail.com> on 2009/12/09 15:30:20 UTC

Inject a bean in a class extending CamelTestSupport

Hi,
I'm testing Normalizer pattern with Camel and I'll be using a POJO to
normalize messages.

My route builder is using bean:normalizer and its methods:
 @Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
            	from("direct:start")
                .choice()
                   
.when().xpath("/employee").to("bean:normalizer?method=employeeToPerson")
                   
.when().xpath("/customer").to("bean:normalizer?method=customerToPerson")
                .end()
                .to("mock:result");
            }
        };
    }

Can I inject the normalizer bean in my CamelNormalizerTest class that
extends CamelTestSupport using annotations and no xml files to define the
context ?

Thanks
-- 
View this message in context: http://old.nabble.com/Inject-a-bean-in-a-class-extending-CamelTestSupport-tp26711104p26711104.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inject a bean in a class extending CamelTestSupport

Posted by jihedamine <ji...@gmail.com>.
Thanks, it worked.

Claus Ibsen-2 wrote:
> 
> On Wed, Dec 9, 2009 at 3:30 PM, jihedamine <ji...@gmail.com> wrote:
>>
>> Hi,
>> I'm testing Normalizer pattern with Camel and I'll be using a POJO to
>> normalize messages.
>>
>> My route builder is using bean:normalizer and its methods:
>>  @Override
>>    protected RouteBuilder createRouteBuilder() {
>>        return new RouteBuilder() {
>>            public void configure() {
>>                from("direct:start")
>>                .choice()
>>
>> .when().xpath("/employee").to("bean:normalizer?method=employeeToPerson")
>>
>> .when().xpath("/customer").to("bean:normalizer?method=customerToPerson")
>>                .end()
>>                .to("mock:result");
>>            }
>>        };
>>    }
>>
>> Can I inject the normalizer bean in my CamelNormalizerTest class that
>> extends CamelTestSupport using annotations and no xml files to define the
>> context ?
>>
> 
> Yeah however instead of using .to("bean:normalizer") you can use a
> .bean(myBean, "customerToPerson")
> 
> Otherwise you need to register your bean in the registry as
> to("bean:xxx") will lookp in the Registry for the bean.
> 
> 
> 
>> Thanks
>> --
>> View this message in context:
>> http://old.nabble.com/Inject-a-bean-in-a-class-extending-CamelTestSupport-tp26711104p26711104.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Author of Camel in Action: http://www.manning.com/ibsen/
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
> 
> 

-- 
View this message in context: http://old.nabble.com/Inject-a-bean-in-a-class-extending-CamelTestSupport-tp26711104p26715545.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Inject a bean in a class extending CamelTestSupport

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Dec 9, 2009 at 3:30 PM, jihedamine <ji...@gmail.com> wrote:
>
> Hi,
> I'm testing Normalizer pattern with Camel and I'll be using a POJO to
> normalize messages.
>
> My route builder is using bean:normalizer and its methods:
>  @Override
>    protected RouteBuilder createRouteBuilder() {
>        return new RouteBuilder() {
>            public void configure() {
>                from("direct:start")
>                .choice()
>
> .when().xpath("/employee").to("bean:normalizer?method=employeeToPerson")
>
> .when().xpath("/customer").to("bean:normalizer?method=customerToPerson")
>                .end()
>                .to("mock:result");
>            }
>        };
>    }
>
> Can I inject the normalizer bean in my CamelNormalizerTest class that
> extends CamelTestSupport using annotations and no xml files to define the
> context ?
>

Yeah however instead of using .to("bean:normalizer") you can use a
.bean(myBean, "customerToPerson")

Otherwise you need to register your bean in the registry as
to("bean:xxx") will lookp in the Registry for the bean.



> Thanks
> --
> View this message in context: http://old.nabble.com/Inject-a-bean-in-a-class-extending-CamelTestSupport-tp26711104p26711104.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus