Now,

1. I added the suggestion to my client-camel-context.xml such as:

   * <!-- Create a client Camel Context -->
    <camel:camelContext id="camel">
        <camel:packageScan>

<camel:package>com.wiredducks.service.routes.test</camel:package>
            <camel:excludes>**.*Excluded*</camel:excludes>
            <camel:includes>**.*</camel:includes>
        </camel:packageScan>

        <!-- Create a Consumer so we can consume messages -->
        <camel:consumerTemplate id="consumer" />
    </camel:camelContext>
*

2. Then I added the rout you said:

    @Override
    public void configure() throws Exception {


from("activemq://Consumer.A.VirtualTopic.TEST").to("seda:TESTING").to("mock://resultClient1");

    } // end configure


3. I un-commented the mock assertions in my JUnit:


*MockEndpoint resultClient1 = camel.getEndpoint("mock://resultClient1",
MockEndpoint.class);
... then ...
resultClient1.expectedMessageCount(1);
*
*
        // Send the test message to make Server Service create our Status
Message
        producerTemplate.sendBody("xxyyzz");

        // now lets assert that the mock endpoint received messages
        resultClient1.assertIsSatisfied();
*



NOW:

A. I did not see Consumer.1 MDP did NOT get the message now.

B. *resultClient1 *expected 1 message but received zero messages.*

*





---
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 Tue, Aug 18, 2009 at 12:27 PM, Mick Knutson <mknut...@baselogic.com>wrote:

> I tried this, but I get a failure on my Mock.
>
> Let me try to step through what I have working:
>
> 1. I start up a camel server via mvn camel:run
> 2. The camel server starts the following route:
>
>    * @Override
>     public void configure() throws Exception {
>         // add tracer as an interceptor so it will log the exchange
> executions at runtime
>         // this can aid us to understand/see how the exchanges is routed
> etc.
>         getContext().addInterceptStrategy(new Tracer());
>
>         from("jms:queue:bets").process(new PlaceBet());
>
>         from("seda:pushStatusUpdate")
>             .process(new VirtualTopicAuditor())
>                 .to(TableServiceImpl.VIRTUAL_TOPIC);
>     }
> *
>
> 3. In another command prompt, I start my unit test which starts another
> client camel context like this:
>
>     *<!-- Create a client Camel Context -->*
> *    <camel:camelContext id="camel">*
> *        <camel:packageScan>*
> *
> <camel:package>com.wiredducks.service.routes.test</camel:package>*
> *            <camel:excludes>**.*Excluded*</camel:excludes>*
> *            <camel:includes>**.*</camel:includes>*
> *        </camel:packageScan>*
>
> *        <!-- Create a Consumer so we can consume messages -->*
> *        <camel:consumerTemplate id="consumer" />*
> *    </camel:camelContext>*
>
> *    <!-- Create a Producer so we can send messages -->*
> *    <camel:template id="producer" />*
>
> *    <bean id="jms"
> class="org.apache.activemq.camel.component.ActiveMQComponent">*
> *        <property name="brokerURL" value="tcp://localhost:61616" />*
> *    </bean>*
>
> *    <bean id="connectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">*
> *        <property name="brokerURL" value="tcp://localhost:61616" />*
> *    </bean>*
>
> *    <bean id="transactionManager"*
> *        class="org.springframework.jms.connection.JmsTransactionManager">
> *
> *        <property name="connectionFactory" ref="connectionFactory" />*
> *    </bean>*
> *    <import resource="clients/test-client1.xml" />*
>     ....*
>     <import resource="clients/test-client11.xml" />*
>
>
> *</beans>*
>
>
> 4. Each client MDP is created and just prints out the message received by
> onMessage()
>
>     *<bean id="test-client1"
> class="com.wiredducks.service.impl.StatusUpdateService">
>        <property name="name" value="test-client1" />
>        <property name="seat" value="1" />
>     </bean>
>
>     <jms:listener-container transaction-manager="transactionManager" >
>         <jms:listener   destination="Consumer.1.VirtualTopic.TEST"
>                         ref="test-client1"
>                         method="onMessage" />
>     </jms:listener-container>
> *
>
>
> 5. My unit tests just forces a message to be sent by calling a
> sendStatusUpdate message from the camel server:
>
>     *...@autowired*
> *    protected SpringCamelContext camel;*
>
> *    @EndpointInject(uri = "mock://resultClient1")*
> *    protected MockEndpoint resultClient1;*
> *   *
> *    @Produce(uri = "direct:start")*
> *    protected ProducerTemplate producerTemplate;*
>
> *    @Test*
> *    public void testSendBetMessage() throws Exception {**       *
> *        *
> *        //MockEndpoint resultClient1 =
> camel.getEndpoint("mock://resultClient1", MockEndpoint.class);***
> *        *
> *        resultClient1.expectedMessageCount(1);*
>
> *        // Send the test message to make Server Service create our Status
> Message*
> *        producerTemplate.sendBody("xxyyzz");*
> *        *
> *        // now lets assert that the mock endpoint received messages*
> *        //resultClient1.assertIsSatisfied();**        *
> *    }*
>
> 6. The server sends a status update message:
>
>     *public boolean sendStatusUpdate(String body) {**        **        *
> *        Map<String, Object> gameState = new HashMap<String, Object>();*
> *        gameState.put("tableId", "123");*
> *        gameState.put("player1", "raise");*
>
> *        //Send message to *
> *        producer.sendBodyAndHeader("seda:pushStatusUpdate", gameState,
> "tableId", "123");*
> *        return true;*
> *    }*
>
> 7. Each of the clients that where setup in the camel client will get the
> message just fine. I have tested this with 10 clients now.
>
> *** In the next email, I will elaborate on the change you suggested.
> ******NOTE: I commented out *//resultClient1.assertIsSatisfied();* in
> order to get the original test to work.
>
>
>
> ---
> 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 17, 2009 at 7:34 AM, Willem Jiang <willem.ji...@gmail.com>wrote:
>
>> If you want to use Mock endpoint to validate the message, you just need to
>> create the route rule like this
>>
>> from("CosumerA.Virtual.Topic").to("mock:endpoint");
>>
>> You don't need to create the MDP yourself.
>>
>> Willem
>>
>>
>> Mick Knutson wrote:
>>
>>> I finally got a working JUnit test that creates a MDP, subscribes to a
>>> AMQ
>>> Virtual Topic, and receives a message. But now that the MDP gets the
>>> message
>>> I am having an issue validating that message.
>>>
>>> How can I re-route this message to a MOCK just for testing purposes?
>>>
>>> ---
>>> 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
>>> ---
>>>
>>>
>>
>

Reply via email to