You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ozzyoli <oz...@gmail.com> on 2014/06/18 10:27:09 UTC

How to mock rabbitmq endpoints?

I'm working on my testing my CamelContext Routes.

I am using a SpringJunit4ClassRunner to run my tests and start my
CamelContext (defined in Spring XML).
I have the*@MockEndpoints* annotation set at the class-level.

How do I reference the mocked equivalents of my RabbitMQ endpoints?

For instance given this RabbitMQ endpoint

rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F

How do I get hold of the mocked version of that mocked endpoint?

@EndpointInject(uri="mock:rabbitmq")

OR

@EndpointInject(uri="mock:rabbitmq://localhost:5672")

OR

@EndpointInject(uri="mock:rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F")

OR

Something else altogether? (I'll admit I havent had much luck with any of
them so far)


Many thanks in advance,
Oli



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-mock-rabbitmq-endpoints-tp5752492.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to mock rabbitmq endpoints?

Posted by Claus Ibsen <cl...@gmail.com>.
Also @EndpointInject is injected before the advice with AFAIR so this
wont work. For that to work we would need to inject some proxy instead
and delegate to the actual endpoint on-demand, which is harder. And
likely could cause side-effects / issues as a Proxy is not "the real
thing", for people using @EndpointInject today as-is.

On Thu, Jun 19, 2014 at 10:54 AM, Claus Ibsen <cl...@gmail.com> wrote:
> @EndpointInject does not support wildcards. So you would need to
> specify the url 100%
>
> On Thu, Jun 19, 2014 at 10:50 AM, Willem Jiang <wi...@gmail.com> wrote:
>> The last one should be OK.
>> How did you define the @MockEndpoints?
>>
>> --
>> Willem Jiang
>>
>> Red Hat, Inc.
>> Web: http://www.redhat.com
>> Blog: http://willemjiang.blogspot.com (English)
>> http://jnn.iteye.com (Chinese)
>> Twitter: willemjiang
>> Weibo: 姜宁willem
>>
>>
>>
>> On June 18, 2014 at 4:27:36 PM, ozzyoli (ozzyoli@gmail.com) wrote:
>>> I'm working on my testing my CamelContext Routes.
>>>
>>> I am using a SpringJunit4ClassRunner to run my tests and start my
>>> CamelContext (defined in Spring XML).
>>> I have the*@MockEndpoints* annotation set at the class-level.
>>>
>>> How do I reference the mocked equivalents of my RabbitMQ endpoints?
>>>
>>> For instance given this RabbitMQ endpoint
>>>
>>> rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F
>>>
>>> How do I get hold of the mocked version of that mocked endpoint?
>>>
>>> @EndpointInject(uri="mock:rabbitmq")
>>>
>>> OR
>>>
>>> @EndpointInject(uri="mock:rabbitmq://localhost:5672")
>>>
>>> OR
>>>
>>> @EndpointInject(uri="mock:rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F")
>>>
>>> OR
>>>
>>> Something else altogether? (I'll admit I havent had much luck with any of
>>> them so far)
>>>
>>>
>>> Many thanks in advance,
>>> Oli
>>>
>>>
>>>
>>> --
>>> View this message in context: http://camel.465427.n5.nabble.com/How-to-mock-rabbitmq-endpoints-tp5752492.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to mock rabbitmq endpoints?

Posted by Claus Ibsen <cl...@gmail.com>.
@EndpointInject does not support wildcards. So you would need to
specify the url 100%

On Thu, Jun 19, 2014 at 10:50 AM, Willem Jiang <wi...@gmail.com> wrote:
> The last one should be OK.
> How did you define the @MockEndpoints?
>
> --
> Willem Jiang
>
> Red Hat, Inc.
> Web: http://www.redhat.com
> Blog: http://willemjiang.blogspot.com (English)
> http://jnn.iteye.com (Chinese)
> Twitter: willemjiang
> Weibo: 姜宁willem
>
>
>
> On June 18, 2014 at 4:27:36 PM, ozzyoli (ozzyoli@gmail.com) wrote:
>> I'm working on my testing my CamelContext Routes.
>>
>> I am using a SpringJunit4ClassRunner to run my tests and start my
>> CamelContext (defined in Spring XML).
>> I have the*@MockEndpoints* annotation set at the class-level.
>>
>> How do I reference the mocked equivalents of my RabbitMQ endpoints?
>>
>> For instance given this RabbitMQ endpoint
>>
>> rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F
>>
>> How do I get hold of the mocked version of that mocked endpoint?
>>
>> @EndpointInject(uri="mock:rabbitmq")
>>
>> OR
>>
>> @EndpointInject(uri="mock:rabbitmq://localhost:5672")
>>
>> OR
>>
>> @EndpointInject(uri="mock:rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F")
>>
>> OR
>>
>> Something else altogether? (I'll admit I havent had much luck with any of
>> them so far)
>>
>>
>> Many thanks in advance,
>> Oli
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/How-to-mock-rabbitmq-endpoints-tp5752492.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to mock rabbitmq endpoints?

Posted by Willem Jiang <wi...@gmail.com>.
The last one should be OK.
How did you define the @MockEndpoints?

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On June 18, 2014 at 4:27:36 PM, ozzyoli (ozzyoli@gmail.com) wrote:
> I'm working on my testing my CamelContext Routes.
>  
> I am using a SpringJunit4ClassRunner to run my tests and start my
> CamelContext (defined in Spring XML).
> I have the*@MockEndpoints* annotation set at the class-level.
>  
> How do I reference the mocked equivalents of my RabbitMQ endpoints?
>  
> For instance given this RabbitMQ endpoint
>  
> rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F  
>  
> How do I get hold of the mocked version of that mocked endpoint?
>  
> @EndpointInject(uri="mock:rabbitmq")
>  
> OR
>  
> @EndpointInject(uri="mock:rabbitmq://localhost:5672")
>  
> OR
>  
> @EndpointInject(uri="mock:rabbitmq://localhost:5672/test?autoDelete=false&password=xxxxxx&routingKey=ipm.adapter&username=guest&vhost=%2F")  
>  
> OR
>  
> Something else altogether? (I'll admit I havent had much luck with any of
> them so far)
>  
>  
> Many thanks in advance,
> Oli
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-mock-rabbitmq-endpoints-tp5752492.html  
> Sent from the Camel - Users mailing list archive at Nabble.com.
>