You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mick Knutson <mk...@baselogic.com> on 2009/08/04 03:21:40 UTC

Unit testing Virtual topics in Camel

I have seen a FUSE posting showing:

*
from("activemq:topic:VirtualTopic.topic").to("activemq:Consumer.example.VirtualTopic.topic");

With the following added to the activemq.xml configuration file:

&lt;broker xmlns="http://activemq.apache.org/schema/core"&gt;
<virtualDestinationInterceptor>
<virtualDestinations>
<virtualTopic name=">" prefix="VirtualTopicConsumers.*."/>
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>
*

I am interested to know if this can be unit tested with an embedded broker?

---
Thank You…

Mick Knutson, President

BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233

Website: http://baselogic.com
Linked IN: http://linkedin.com/in/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---

Re: Unit testing Virtual topics in Camel

Posted by Willem Jiang <wi...@gmail.com>.
Oh, I just copied it from the camel-spring JUnit test[1].
The endpoints can be used in the Java routing rule.

[1]https://svn.apache.org/repos/asf/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/route/MyRouteBuilder.java

Willem

Mick Knutson wrote:
> Can you explain the 2nd option?
> Why are you adding endpopints to the Spring Context?
> 
>   <camelContext xmlns="http://camel.apache.org/schema/spring">
>        <packageScan>
>            *<package>org.apache.camel.spring.config.scan</package>*
>            <excludes>**/*Excluded*</excludes>
>            <includes>**/*</includes>
>        </packageScan>
>         *<endpoint id="start" uri="direct:start"/>
>        <endpoint id="result" uri="mock:end"/>*
>    </camelContext>
> 
> Why not just define them in the Unit Test?
> 
> ---
> Thank You…
> 
> Mick Knutson, President
> 
> BASE Logic, Inc.
> Enterprise Architecture, Design, Mentoring & Agile Consulting
> p. (866) BLiNC-411: (254-6241-1)
> f. (415) 685-4233
> 
> Website: http://baselogic.com
> Linked IN: http://linkedin.com/in/mickknutson
> Vacation Rental: http://tahoe.baselogic.com
> ---
> 
> 
> 
> On Mon, Aug 3, 2009 at 7:27 PM, Willem Jiang <wi...@gmail.com> wrote:
> 
>> Hi,
>>
>> Camel support to pick up the Java DSL routing rule from spring
>> configuration.
>>
>> You can include the activemq.xml in your camel spring configuration file,
>> then you can create an unit test with the embedded AcitveMQ broker and you
>> also need to put the activemq-camel jar into your ClassPath.
>>
>> Here are the examples which helps you to specify the RouteBuidler in the
>> spring.
>>
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>       xsi:schemaLocation="
>>       http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>>       http://camel.apache.org/schema/spring
>> http://camel.apache.org/schema/spring/camel-spring.xsd
>>    ">
>>
>>  <!-- START SNIPPET: example -->
>>  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>>    <routeBuilder ref="myRoutes"/>
>>  </camelContext>
>>  <!-- END SNIPPET: example -->
>>  <bean id="myRoutes"
>> class="org.apache.camel.spring.RouteRefCamelContextFactoryBeanTest$MyRoutes"/>
>> </beans>
>>
>> or using the packageScan to find the RouteBuilder by specify the package
>> name.
>>   <camelContext xmlns="http://camel.apache.org/schema/spring">
>>        <packageScan>
>>            <package>org.apache.camel.spring.config.scan</package>
>>            <excludes>**/*Excluded*</excludes>
>>            <includes>**/*</includes>
>>        </packageScan>
>>
>>        <endpoint id="start" uri="direct:start"/>
>>        <endpoint id="result" uri="mock:end"/>
>>    </camelContext>
>>
>>
>> Willem
>>
>>
>> Mick Knutson wrote:
>>
>>> I have seen a FUSE posting showing:
>>>
>>> *
>>>
>>> from("activemq:topic:VirtualTopic.topic").to("activemq:Consumer.example.VirtualTopic.topic");
>>>
>>> With the following added to the activemq.xml configuration file:
>>>
>>> &lt;broker xmlns="http://activemq.apache.org/schema/core"&gt;
>>> <virtualDestinationInterceptor>
>>> <virtualDestinations>
>>> <virtualTopic name=">" prefix="VirtualTopicConsumers.*."/>
>>> </virtualDestinations>
>>> </virtualDestinationInterceptor>
>>> </destinationInterceptors>
>>> *
>>>
>>> I am interested to know if this can be unit tested with an embedded
>>> broker?
>>>
>>> ---
>>> Thank You…
>>>
>>> Mick Knutson, President
>>>
>>> BASE Logic, Inc.
>>> Enterprise Architecture, Design, Mentoring & Agile Consulting
>>> p. (866) BLiNC-411: (254-6241-1)
>>> f. (415) 685-4233
>>>
>>> Website: http://baselogic.com
>>> Linked IN: http://linkedin.com/in/mickknutson
>>> Vacation Rental: http://tahoe.baselogic.com
>>> ---
>>>
>>>
> 


Re: Unit testing Virtual topics in Camel

Posted by Mick Knutson <mk...@baselogic.com>.
Can you explain the 2nd option?
Why are you adding endpopints to the Spring Context?

  <camelContext xmlns="http://camel.apache.org/schema/spring">
       <packageScan>
           *<package>org.apache.camel.spring.config.scan</package>*
           <excludes>**/*Excluded*</excludes>
           <includes>**/*</includes>
       </packageScan>
        *<endpoint id="start" uri="direct:start"/>
       <endpoint id="result" uri="mock:end"/>*
   </camelContext>

Why not just define them in the Unit Test?

---
Thank You…

Mick Knutson, President

BASE Logic, Inc.
Enterprise Architecture, Design, Mentoring & Agile Consulting
p. (866) BLiNC-411: (254-6241-1)
f. (415) 685-4233

Website: http://baselogic.com
Linked IN: http://linkedin.com/in/mickknutson
Vacation Rental: http://tahoe.baselogic.com
---



On Mon, Aug 3, 2009 at 7:27 PM, Willem Jiang <wi...@gmail.com> wrote:

> Hi,
>
> Camel support to pick up the Java DSL routing rule from spring
> configuration.
>
> You can include the activemq.xml in your camel spring configuration file,
> then you can create an unit test with the embedded AcitveMQ broker and you
> also need to put the activemq-camel jar into your ClassPath.
>
> Here are the examples which helps you to specify the RouteBuidler in the
> spring.
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation="
>       http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>       http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
>    ">
>
>  <!-- START SNIPPET: example -->
>  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
>    <routeBuilder ref="myRoutes"/>
>  </camelContext>
>  <!-- END SNIPPET: example -->
>  <bean id="myRoutes"
> class="org.apache.camel.spring.RouteRefCamelContextFactoryBeanTest$MyRoutes"/>
> </beans>
>
> or using the packageScan to find the RouteBuilder by specify the package
> name.
>   <camelContext xmlns="http://camel.apache.org/schema/spring">
>        <packageScan>
>            <package>org.apache.camel.spring.config.scan</package>
>            <excludes>**/*Excluded*</excludes>
>            <includes>**/*</includes>
>        </packageScan>
>
>        <endpoint id="start" uri="direct:start"/>
>        <endpoint id="result" uri="mock:end"/>
>    </camelContext>
>
>
> Willem
>
>
> Mick Knutson wrote:
>
>> I have seen a FUSE posting showing:
>>
>> *
>>
>> from("activemq:topic:VirtualTopic.topic").to("activemq:Consumer.example.VirtualTopic.topic");
>>
>> With the following added to the activemq.xml configuration file:
>>
>> &lt;broker xmlns="http://activemq.apache.org/schema/core"&gt;
>> <virtualDestinationInterceptor>
>> <virtualDestinations>
>> <virtualTopic name=">" prefix="VirtualTopicConsumers.*."/>
>> </virtualDestinations>
>> </virtualDestinationInterceptor>
>> </destinationInterceptors>
>> *
>>
>> I am interested to know if this can be unit tested with an embedded
>> broker?
>>
>> ---
>> Thank You…
>>
>> Mick Knutson, President
>>
>> BASE Logic, Inc.
>> Enterprise Architecture, Design, Mentoring & Agile Consulting
>> p. (866) BLiNC-411: (254-6241-1)
>> f. (415) 685-4233
>>
>> Website: http://baselogic.com
>> Linked IN: http://linkedin.com/in/mickknutson
>> Vacation Rental: http://tahoe.baselogic.com
>> ---
>>
>>
>

Re: Unit testing Virtual topics in Camel

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Camel support to pick up the Java DSL routing rule from spring 
configuration.

You can include the activemq.xml in your camel spring configuration 
file, then you can create an unit test with the embedded AcitveMQ broker 
and you also need to put the activemq-camel jar into your ClassPath.

Here are the examples which helps you to specify the RouteBuidler in the 
spring.

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
     ">

   <!-- START SNIPPET: example -->
   <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
     <routeBuilder ref="myRoutes"/>
   </camelContext>
   <!-- END SNIPPET: example -->
   <bean id="myRoutes" 
class="org.apache.camel.spring.RouteRefCamelContextFactoryBeanTest$MyRoutes"/>
</beans>

or using the packageScan to find the RouteBuilder by specify the package 
name.
    <camelContext xmlns="http://camel.apache.org/schema/spring">
         <packageScan>
             <package>org.apache.camel.spring.config.scan</package>
             <excludes>**/*Excluded*</excludes>
             <includes>**/*</includes>
         </packageScan>

         <endpoint id="start" uri="direct:start"/>
         <endpoint id="result" uri="mock:end"/>
     </camelContext>


Willem

Mick Knutson wrote:
> I have seen a FUSE posting showing:
> 
> *
> from("activemq:topic:VirtualTopic.topic").to("activemq:Consumer.example.VirtualTopic.topic");
> 
> With the following added to the activemq.xml configuration file:
> 
> &lt;broker xmlns="http://activemq.apache.org/schema/core"&gt;
> <virtualDestinationInterceptor>
> <virtualDestinations>
> <virtualTopic name=">" prefix="VirtualTopicConsumers.*."/>
> </virtualDestinations>
> </virtualDestinationInterceptor>
> </destinationInterceptors>
> *
> 
> I am interested to know if this can be unit tested with an embedded broker?
> 
> ---
> Thank You…
> 
> Mick Knutson, President
> 
> BASE Logic, Inc.
> Enterprise Architecture, Design, Mentoring & Agile Consulting
> p. (866) BLiNC-411: (254-6241-1)
> f. (415) 685-4233
> 
> Website: http://baselogic.com
> Linked IN: http://linkedin.com/in/mickknutson
> Vacation Rental: http://tahoe.baselogic.com
> ---
>