You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by XiaoPeng Li <xp...@talend.com> on 2011/08/29 04:39:54 UTC

How to test routes in exported OSGI bundles using Camel Test Framework

Hi

Here is my question:

I want to unit test my routes using Camel Test Framework, however these routes are exported as OSGI bundles which only contains binary classes or resources. Thus it's hard to Mock the real endpoint using Mock component, would someone give some suggestions?

I am using Camel 2.7.2

Thanks

Xiaopeng Li

RE: ??: How to test routes in exported OSGI bundles using Camel Test Framework

Posted by XiaoPeng Li <xp...@talend.com>.
Hi

Thanks for reply.

I choose to using Camel Properties component to replace the URI in Endpoint with property, and then users can have another version properties only for test.



-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@gmail.com] 
Sent: Monday, August 29, 2011 6:51 PM
To: users@camel.apache.org
Subject: Re: ??: How to test routes in exported OSGI bundles using Camel Test Framework

You can get the mock endpoint from camel context.
If you want to replace it with real component with mock enpdoint, you 
may need to change the route yourself.


On 8/29/11 11:22 AM, XiaoPeng Li wrote:
> Hi Jiang
>
> Thanks for your reply.
>
> Sorry about the unclear description. I mean someone has finished a Route with some logic endpoints, and then exported it as an OSGI bundle. And if he/she wants to test the Route, how to mock the real endpoints?
>
> In a typical route test, users have to provide a route to test in "createRouteBuilder()" if using "org.apache.camel.test.junit4.CamelTestSupport". And If the route has been finished and only binary classes are provided, how to do such Mock components replacement?
>
> For example, how to add the "mock:result" endpoint?
> " @EndpointInject(uri = "mock:result")
>    protected MockEndpoint resultEndpoint;"
>
> Maybe I got some misunderstanding about Camel Test framework, I thought it was due to route developers who do the mock component replacement.
>
> Thanks
>
> Xiaopeng Li
>
> -----邮件原件-----
> 发件人: Willem Jiang [mailto:willem.jiang@gmail.com]
> 发送时间: 2011年8月29日 10:58
> 收件人: users@camel.apache.org
> 主题: Re: How to test routes in exported OSGI bundles using Camel Test Framework
>
> I don't get what you are asking for.
> If you want to test the route by using the Camel Test Framework, you
> don't need to care about the if the route is in a OSGi bundle or not.
> The Mock endpoint can do it job if you setup the test framework rightly.
>
> On Mon Aug 29 10:39:54 2011, XiaoPeng Li wrote:
>> Hi
>>
>> Here is my question:
>>
>> I want to unit test my routes using Camel Test Framework, however these routes are exported as OSGI bundles which only contains binary classes or resources. Thus it's hard to Mock the real endpoint using Mock component, would someone give some suggestions?
>>
>> I am using Camel 2.7.2
>>
>> Thanks
>>
>> Xiaopeng Li
>
>
>


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

Re: 答复: How to test routes in exported OSGI bundles using Camel Test Framework

Posted by Willem Jiang <wi...@gmail.com>.
You can get the mock endpoint from camel context.
If you want to replace it with real component with mock enpdoint, you 
may need to change the route yourself.


On 8/29/11 11:22 AM, XiaoPeng Li wrote:
> Hi Jiang
>
> Thanks for your reply.
>
> Sorry about the unclear description. I mean someone has finished a Route with some logic endpoints, and then exported it as an OSGI bundle. And if he/she wants to test the Route, how to mock the real endpoints?
>
> In a typical route test, users have to provide a route to test in "createRouteBuilder()" if using "org.apache.camel.test.junit4.CamelTestSupport". And If the route has been finished and only binary classes are provided, how to do such Mock components replacement?
>
> For example, how to add the "mock:result" endpoint?
> " @EndpointInject(uri = "mock:result")
>    protected MockEndpoint resultEndpoint;"
>
> Maybe I got some misunderstanding about Camel Test framework, I thought it was due to route developers who do the mock component replacement.
>
> Thanks
>
> Xiaopeng Li
>
> -----邮件原件-----
> 发件人: Willem Jiang [mailto:willem.jiang@gmail.com]
> 发送时间: 2011年8月29日 10:58
> 收件人: users@camel.apache.org
> 主题: Re: How to test routes in exported OSGI bundles using Camel Test Framework
>
> I don't get what you are asking for.
> If you want to test the route by using the Camel Test Framework, you
> don't need to care about the if the route is in a OSGi bundle or not.
> The Mock endpoint can do it job if you setup the test framework rightly.
>
> On Mon Aug 29 10:39:54 2011, XiaoPeng Li wrote:
>> Hi
>>
>> Here is my question:
>>
>> I want to unit test my routes using Camel Test Framework, however these routes are exported as OSGI bundles which only contains binary classes or resources. Thus it's hard to Mock the real endpoint using Mock component, would someone give some suggestions?
>>
>> I am using Camel 2.7.2
>>
>> Thanks
>>
>> Xiaopeng Li
>
>
>


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

答复: How to test routes in exported OSGI bundles using Camel Test Framework

Posted by XiaoPeng Li <xp...@talend.com>.
Hi Jiang

Thanks for your reply.

Sorry about the unclear description. I mean someone has finished a Route with some logic endpoints, and then exported it as an OSGI bundle. And if he/she wants to test the Route, how to mock the real endpoints?

In a typical route test, users have to provide a route to test in "createRouteBuilder()" if using "org.apache.camel.test.junit4.CamelTestSupport". And If the route has been finished and only binary classes are provided, how to do such Mock components replacement?

For example, how to add the "mock:result" endpoint?
" @EndpointInject(uri = "mock:result")
  protected MockEndpoint resultEndpoint;"

Maybe I got some misunderstanding about Camel Test framework, I thought it was due to route developers who do the mock component replacement.

Thanks

Xiaopeng Li

-----邮件原件-----
发件人: Willem Jiang [mailto:willem.jiang@gmail.com] 
发送时间: 2011年8月29日 10:58
收件人: users@camel.apache.org
主题: Re: How to test routes in exported OSGI bundles using Camel Test Framework

I don't get what you are asking for.
If you want to test the route by using the Camel Test Framework, you 
don't need to care about the if the route is in a OSGi bundle or not.
The Mock endpoint can do it job if you setup the test framework rightly.
 
On Mon Aug 29 10:39:54 2011, XiaoPeng Li wrote:
> Hi
> 
> Here is my question:
> 
> I want to unit test my routes using Camel Test Framework, however these routes are exported as OSGI bundles which only contains binary classes or resources. Thus it's hard to Mock the real endpoint using Mock component, would someone give some suggestions?
> 
> I am using Camel 2.7.2
> 
> Thanks
> 
> Xiaopeng Li



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

Re: How to test routes in exported OSGI bundles using Camel Test Framework

Posted by Willem Jiang <wi...@gmail.com>.
I don't get what you are asking for.
If you want to test the route by using the Camel Test Framework, you 
don't need to care about the if the route is in a OSGi bundle or not.
The Mock endpoint can do it job if you setup the test framework rightly.
 
On Mon Aug 29 10:39:54 2011, XiaoPeng Li wrote:
> Hi
> 
> Here is my question:
> 
> I want to unit test my routes using Camel Test Framework, however these routes are exported as OSGI bundles which only contains binary classes or resources. Thus it's hard to Mock the real endpoint using Mock component, would someone give some suggestions?
> 
> I am using Camel 2.7.2
> 
> Thanks
> 
> Xiaopeng Li



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