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/22 22:26:55 UTC

frustration with multiple mock endpoints in 1 unit test.

I have a unit test that has a wiretap that routes the message to a mock
endpoint.
Here is what works:

    @EndpointInject(uri = "mock:resultAllClients")
    protected MockEndpoint resultAllClients;

    @EndpointInject(uri = "mock:resultClient1")
    protected MockEndpoint resultClient1;
    @EndpointInject(uri = "mock:resultClient2")
    protected MockEndpoint resultClient2;
    @EndpointInject(uri = "mock:resultClient3")
    protected MockEndpoint resultClient3;
    @EndpointInject(uri = "mock:resultClient4")
    protected MockEndpoint resultClient4;

    @Test
    public void testSendBetMessage() throws Exception {
        log.info("Send a test message to Table Service");

        //resultAllClients.expectedMinimumMessageCount(3);
        resultClient1.expectedMessageCount(1);
        resultClient2.expectedMessageCount(1);
        //resultClient3.expectedMessageCount(1);
        //resultClient4.expectedMessageCount(1);


        // Send the test message to make Server Service create our Status
Message
        producerTemplate.sendBody("jms:queue:bets",
                ExchangePattern.InOnly, 22);

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

        //resultAllClients.assertIsSatisfied();
        log.info("XXXXXXXXXX DONE
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

    }

    /*@After
    public void finalizeTests() {
        // resultAllClients.reset();
        resultClient1.reset();
        resultClient2.reset();
        resultClient3.reset();
        // resultClient4.reset();
    }*/



This is in 1 unit test class and the way it is above has all assertions
pass.
If any of the following things change, I get:

java.lang.AssertionError: mock://resultClient1 Received message count.
Expected: <1> but was: <0>


1. If I uncomment the finalizeTests() method, the error starts.

2. If I uncomment resultClient3, resultClient4 it might start working, then
randomly it will show up again and I have to comment them out in order for
the test to pass again.


Is there some bug/defect in the Mock that I have not googled?



---
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: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
Thanks Clause, I did that, and here is what I see for my client 1 mock:

[thread 3: seda://resultClient1] TraceInterceptor               INFO
ID-mick-knutsons-macbook-local-58874-1251032417363-0-22 >>> *
from(seda://resultClient1)* --> com.wiredducks.routes.test.ClientRoutes$*
ClientRouteAuditor*@2d2f6d60, Pattern:InOnly, BodyType:String, Body:Someone
called us with this number ActiveMQMapMessage {commandId = 5,
responseRequired = true, messageId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1:1,
originalDestination = null, originalTransactionId = null, producerId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1, destination =
topic://VirtualTopic.Table.1, transactionId = null, expiration = 0,
timestamp = 1251032420921, arrival = 0, brokerInTime = 1251032420922,
brokerOutTime = 1251032420933, correlationId = null, replyTo = null,
persistent = true, type = null, priority = 4, groupID = null, groupSequence
= 0, targetConsumerId = null, compressed = false, userID = null, content =
org.apache.activemq.util.ByteSequence@5a6ed23a, marshalledProperties =
org.apache.activemq.util.ByteSequence@21ac0c38, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {tableId=1},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
ActiveMQMapMessage{ theTable = {} }

With that, I added an audit processor to ensure I was able to see the
message getting to the seda://resultClient1 queue.

So in this same run, a bit further down the stack, I see this:


[thread 3: seda://resultClient1] TraceInterceptor               INFO
ID-mick-knutsons-macbook-local-58874-1251032417363-0-22
>>>*from(seda://resultClient1) -->
*com.wiredducks.routes.test.ClientRoutes$ClientRouteAuditor@2d2f6d60,
Pattern:InOnly, BodyType:String, Body:Someone called us with this number
ActiveMQMapMessage {commandId = 5, responseRequired = true, messageId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1:1,
originalDestination = null, originalTransactionId = null, producerId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1, destination =
topic://VirtualTopic.Table.1, transactionId = null, expiration = 0,
timestamp = 1251032420921, arrival = 0, brokerInTime = 1251032420922,
brokerOutTime = 1251032420933, correlationId = null, replyTo = null,
persistent = true, type = null, priority = 4, groupID = null, groupSequence
= 0, targetConsumerId = null, compressed = false, userID = null, content =
org.apache.activemq.util.ByteSequence@5a6ed23a, marshalledProperties =
org.apache.activemq.util.ByteSequence@21ac0c38, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {tableId=1},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
ActiveMQMapMessage{ theTable = {} }
*[thread 3: seda://resultClient1] ClientRoutes                   INFO  //---
start ClientRouteAuditor ---//*
[thread 3: seda://resultClient1] ClientRoutes                   INFO
tableId null
[thread 3: seda://resultClient1] ClientRoutes                   INFO
Someone called us with this number ActiveMQMapMessage {commandId = 5,
responseRequired = true, messageId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1:1,
originalDestination = null, originalTransactionId = null, producerId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1, destination =
topic://VirtualTopic.Table.1, transactionId = null, expiration = 0,
timestamp = 1251032420921, arrival = 0, brokerInTime = 1251032420922,
brokerOutTime = 1251032420933, correlationId = null, replyTo = null,
persistent = true, type = null, priority = 4, groupID = null, groupSequence
= 0, targetConsumerId = null, compressed = false, userID = null, content =
org.apache.activemq.util.ByteSequence@5a6ed23a, marshalledProperties =
org.apache.activemq.util.ByteSequence@21ac0c38, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {tableId=1},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
ActiveMQMapMessage{ theTable = {} }
[thread 3: seda://resultClient1] ClientRoutes                   INFO  //---
end ClientRouteAuditor ---//

[thread 3: seda://resultClient1] TraceInterceptor               INFO
ID-mick-knutsons-macbook-local-58874-1251032417363-0-22 >>>
com.wiredducks.routes.test.ClientRoutes$ClientRouteAuditor@2d2f6d60 --> *
mock://resultAllClients,* Pattern:InOnly, BodyType:String, Body:Someone
called us with this number ActiveMQMapMessage {commandId = 5,
responseRequired = true, messageId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1:1,
originalDestination = null, originalTransactionId = null, producerId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:11:1:1, destination =
topic://VirtualTopic.Table.1, transactionId = null, expiration = 0,
timestamp = 1251032420921, arrival = 0, brokerInTime = 1251032420922,
brokerOutTime = 1251032420933, correlationId = null, replyTo = null,
persistent = true, type = null, priority = 4, groupID = null, groupSequence
= 0, targetConsumerId = null, compressed = false, userID = null, content =
org.apache.activemq.util.ByteSequence@5a6ed23a, marshalledProperties =
org.apache.activemq.util.ByteSequence@21ac0c38, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {tableId=1},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
ActiveMQMapMessage{ theTable = {} }


No what puzzles me as I look through this, I do not see mock://resultClient1
anywhere.

So I took out the wiretap and sued this route:
        from("seda://resultClient1")
            .process(new ClientRouteAuditor())
                    .to("mock://resultClient1");


Then I see the mock:

thread 3: seda://resultClient1] TraceInterceptor               INFO
ID-mick-knutsons-macbook-local-59515-1251033193324-0-25 >>>
com.wiredducks.routes.test.ClientRoutes$ClientRouteAuditor@266883cb
-->*mock://resultClient1
*, Pattern:InOnly, BodyType:String, Body:Someone called us with this number
ActiveMQMapMessage {commandId = 5, responseRequired = true, messageId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:12:1:1:1,
originalDestination = null, originalTransactionId = null, producerId =
ID:mick-knutsons-macbook.local-54963-1251028089270-2:12:1:1, destination =
topic://VirtualTopic.Table.1, transactionId = null, expiration = 0,
timestamp = 1251033197564, arrival = 0, brokerInTime = 1251033197564,
brokerOutTime = 1251033197566, correlationId = null, replyTo = null,
persistent = true, type = null, priority = 4, groupID = null, groupSequence
= 0, targetConsumerId = null, compressed = false, userID = null, content =
org.apache.activemq.util.ByteSequence@385eb0bb, marshalledProperties =
org.apache.activemq.util.ByteSequence@50a4e1e6, dataStructure = null,
redeliveryCounter = 0, size = 0, properties = {tableId=1},
readOnlyProperties = true, readOnlyBody = true, droppable = false}
ActiveMQMapMessage{ theTable = {} }


But still get:

java.lang.AssertionError: *mock://resultClient1* Received message count.
Expected: <1> but was: <0>


---
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 Sun, Aug 23, 2009 at 5:37 AM, Claus Ibsen <cl...@gmail.com> wrote:

> On Sun, Aug 23, 2009 at 2:18 PM, Mick Knutson<mk...@baselogic.com>
> wrote:
> > I have tried everything I can at least 20 times. I really appreciate the
> > help on this one as there is no pattern for me to follow to solve this.
> > Sometimes it works, and sometimes it doesn't.
> >
> > I also tried this in the route (none successful):
> >
> >
> >
> from("activemq:Consumer.1.VirtualTopic.Table.1").wireTap("mock://resultAllClients").to("mock:resultClient1");
> >
> >        from("seda:resultClient1").to("mock:resultClient1");
> >
> >        from("seda:resultClient2").to("mock:resultClient2");
> >
> >
> > Is there any advise anyone can give me to understand a better way to
> DEBUG
> > through the routes and messages?
> >
>
> Use the tracer
> http://camel.apache.org/tracer
>
> > ---
> > 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 Sun, Aug 23, 2009 at 5:09 AM, Mick Knutson <mknutson@baselogic.com
> >wrote:
> >
> >> Here is the 1 Route file I have:
> >>
> >>     @Override
> >>     public void configure() throws Exception {
> >>         log.info("//@@@@@ CLIENT ROUTES
> >> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//");
> >>
> >>
> >>
> //from("activemq:Consumer.1.VirtualTopic.Table.1").wireTap("mock://resultAllClients").to("mock:resultClient1");
> >>
> >>
> >>
> from("seda:resultClient1").wireTap("mock://resultAllClients").to("mock:resultClient1");
> >>
> >>
> from("seda:resultClient2").wireTap("mock://resultAllClients").to("mock:resultClient2");
> >>
> >>
> from("seda:resultClient3").wireTap("mock://resultAllClients").to("mock:resultClient3");
> >>
> >>
> from("seda:resultClient4").wireTap("mock://resultAllClients").to("mock:resultClient4");
> >>
> >>
> from("seda:resultClient5").wireTap("mock://resultAllClients").to("mock:resultClient5");
> >>
> >>
> from("seda:resultClient6").wireTap("mock://resultAllClients").to("mock:resultClient6");
> >>
> >>
> from("seda:resultClient7").wireTap("mock://resultAllClients").to("mock:resultClient7");
> >>
> >>
> from("seda:resultClient8").wireTap("mock://resultAllClients").to("mock:resultClient8");
> >>
> >>
> from("seda:resultClient9").wireTap("mock://resultAllClients").to("mock:resultClient9");
> >>
> >>
> from("seda:resultClient10").wireTap("mock://resultAllClients").to("mock:resultClient10");
> >>
> >>
> from("seda:resultClient11").wireTap("mock://resultAllClients").to("mock:resultClient11");
> >>
> >>     } // end configure
> >>
> >>
> >> ---
> >> 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 Sun, Aug 23, 2009 at 3:14 AM, Willem Jiang <willem.jiang@gmail.com
> >wrote:
> >>
> >>> Hi Mick,
> >>>
> >>> Can you show me the route rule ?
> >>> It will help us to trace the issue :)
> >>>
> >>> Willem
> >>>
> >>>
> >>> Mick Knutson wrote:
> >>>
> >>>> I have a unit test that has a wiretap that routes the message to a
> mock
> >>>> endpoint.
> >>>> Here is what works:
> >>>>
> >>>>    @EndpointInject(uri = "mock:resultAllClients")
> >>>>    protected MockEndpoint resultAllClients;
> >>>>
> >>>>    @EndpointInject(uri = "mock:resultClient1")
> >>>>    protected MockEndpoint resultClient1;
> >>>>    @EndpointInject(uri = "mock:resultClient2")
> >>>>    protected MockEndpoint resultClient2;
> >>>>    @EndpointInject(uri = "mock:resultClient3")
> >>>>    protected MockEndpoint resultClient3;
> >>>>    @EndpointInject(uri = "mock:resultClient4")
> >>>>    protected MockEndpoint resultClient4;
> >>>>
> >>>>    @Test
> >>>>    public void testSendBetMessage() throws Exception {
> >>>>        log.info("Send a test message to Table Service");
> >>>>
> >>>>        //resultAllClients.expectedMinimumMessageCount(3);
> >>>>        resultClient1.expectedMessageCount(1);
> >>>>        resultClient2.expectedMessageCount(1);
> >>>>        //resultClient3.expectedMessageCount(1);
> >>>>        //resultClient4.expectedMessageCount(1);
> >>>>
> >>>>
> >>>>        // Send the test message to make Server Service create our
> Status
> >>>> Message
> >>>>        producerTemplate.sendBody("jms:queue:bets",
> >>>>                ExchangePattern.InOnly, 22);
> >>>>
> >>>>        // now lets assert that the mock endpoint received messages
> >>>>        resultClient1.assertIsSatisfied();
> >>>>        resultClient2.assertIsSatisfied();
> >>>>        //resultClient3.assertIsSatisfied();
> >>>>        //resultClient4.assertIsSatisfied();
> >>>>
> >>>>        //resultAllClients.assertIsSatisfied();
> >>>>        log.info("XXXXXXXXXX DONE
> >>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> >>>>
> >>>>    }
> >>>>
> >>>>    /*@After
> >>>>    public void finalizeTests() {
> >>>>        // resultAllClients.reset();
> >>>>        resultClient1.reset();
> >>>>        resultClient2.reset();
> >>>>        resultClient3.reset();
> >>>>        // resultClient4.reset();
> >>>>    }*/
> >>>>
> >>>>
> >>>>
> >>>> This is in 1 unit test class and the way it is above has all
> assertions
> >>>> pass.
> >>>> If any of the following things change, I get:
> >>>>
> >>>> java.lang.AssertionError: mock://resultClient1 Received message count.
> >>>> Expected: <1> but was: <0>
> >>>>
> >>>>
> >>>> 1. If I uncomment the finalizeTests() method, the error starts.
> >>>>
> >>>> 2. If I uncomment resultClient3, resultClient4 it might start working,
> >>>> then
> >>>> randomly it will show up again and I have to comment them out in order
> >>>> for
> >>>> the test to pass again.
> >>>>
> >>>>
> >>>> Is there some bug/defect in the Mock that I have not googled?
> >>>>
> >>>>
> >>>>
> >>>> ---
> >>>> 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
> >>>> ---
> >>>>
> >>>>
> >>>
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Claus Ibsen <cl...@gmail.com>.
On Sun, Aug 23, 2009 at 2:18 PM, Mick Knutson<mk...@baselogic.com> wrote:
> I have tried everything I can at least 20 times. I really appreciate the
> help on this one as there is no pattern for me to follow to solve this.
> Sometimes it works, and sometimes it doesn't.
>
> I also tried this in the route (none successful):
>
>
> from("activemq:Consumer.1.VirtualTopic.Table.1").wireTap("mock://resultAllClients").to("mock:resultClient1");
>
>        from("seda:resultClient1").to("mock:resultClient1");
>
>        from("seda:resultClient2").to("mock:resultClient2");
>
>
> Is there any advise anyone can give me to understand a better way to DEBUG
> through the routes and messages?
>

Use the tracer
http://camel.apache.org/tracer

> ---
> 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 Sun, Aug 23, 2009 at 5:09 AM, Mick Knutson <mk...@baselogic.com>wrote:
>
>> Here is the 1 Route file I have:
>>
>>     @Override
>>     public void configure() throws Exception {
>>         log.info("//@@@@@ CLIENT ROUTES
>> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//");
>>
>>
>> //from("activemq:Consumer.1.VirtualTopic.Table.1").wireTap("mock://resultAllClients").to("mock:resultClient1");
>>
>>
>> from("seda:resultClient1").wireTap("mock://resultAllClients").to("mock:resultClient1");
>>
>> from("seda:resultClient2").wireTap("mock://resultAllClients").to("mock:resultClient2");
>>
>> from("seda:resultClient3").wireTap("mock://resultAllClients").to("mock:resultClient3");
>>
>> from("seda:resultClient4").wireTap("mock://resultAllClients").to("mock:resultClient4");
>>
>> from("seda:resultClient5").wireTap("mock://resultAllClients").to("mock:resultClient5");
>>
>> from("seda:resultClient6").wireTap("mock://resultAllClients").to("mock:resultClient6");
>>
>> from("seda:resultClient7").wireTap("mock://resultAllClients").to("mock:resultClient7");
>>
>> from("seda:resultClient8").wireTap("mock://resultAllClients").to("mock:resultClient8");
>>
>> from("seda:resultClient9").wireTap("mock://resultAllClients").to("mock:resultClient9");
>>
>> from("seda:resultClient10").wireTap("mock://resultAllClients").to("mock:resultClient10");
>>
>> from("seda:resultClient11").wireTap("mock://resultAllClients").to("mock:resultClient11");
>>
>>     } // end configure
>>
>>
>> ---
>> 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 Sun, Aug 23, 2009 at 3:14 AM, Willem Jiang <wi...@gmail.com>wrote:
>>
>>> Hi Mick,
>>>
>>> Can you show me the route rule ?
>>> It will help us to trace the issue :)
>>>
>>> Willem
>>>
>>>
>>> Mick Knutson wrote:
>>>
>>>> I have a unit test that has a wiretap that routes the message to a mock
>>>> endpoint.
>>>> Here is what works:
>>>>
>>>>    @EndpointInject(uri = "mock:resultAllClients")
>>>>    protected MockEndpoint resultAllClients;
>>>>
>>>>    @EndpointInject(uri = "mock:resultClient1")
>>>>    protected MockEndpoint resultClient1;
>>>>    @EndpointInject(uri = "mock:resultClient2")
>>>>    protected MockEndpoint resultClient2;
>>>>    @EndpointInject(uri = "mock:resultClient3")
>>>>    protected MockEndpoint resultClient3;
>>>>    @EndpointInject(uri = "mock:resultClient4")
>>>>    protected MockEndpoint resultClient4;
>>>>
>>>>    @Test
>>>>    public void testSendBetMessage() throws Exception {
>>>>        log.info("Send a test message to Table Service");
>>>>
>>>>        //resultAllClients.expectedMinimumMessageCount(3);
>>>>        resultClient1.expectedMessageCount(1);
>>>>        resultClient2.expectedMessageCount(1);
>>>>        //resultClient3.expectedMessageCount(1);
>>>>        //resultClient4.expectedMessageCount(1);
>>>>
>>>>
>>>>        // Send the test message to make Server Service create our Status
>>>> Message
>>>>        producerTemplate.sendBody("jms:queue:bets",
>>>>                ExchangePattern.InOnly, 22);
>>>>
>>>>        // now lets assert that the mock endpoint received messages
>>>>        resultClient1.assertIsSatisfied();
>>>>        resultClient2.assertIsSatisfied();
>>>>        //resultClient3.assertIsSatisfied();
>>>>        //resultClient4.assertIsSatisfied();
>>>>
>>>>        //resultAllClients.assertIsSatisfied();
>>>>        log.info("XXXXXXXXXX DONE
>>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>>>
>>>>    }
>>>>
>>>>    /*@After
>>>>    public void finalizeTests() {
>>>>        // resultAllClients.reset();
>>>>        resultClient1.reset();
>>>>        resultClient2.reset();
>>>>        resultClient3.reset();
>>>>        // resultClient4.reset();
>>>>    }*/
>>>>
>>>>
>>>>
>>>> This is in 1 unit test class and the way it is above has all assertions
>>>> pass.
>>>> If any of the following things change, I get:
>>>>
>>>> java.lang.AssertionError: mock://resultClient1 Received message count.
>>>> Expected: <1> but was: <0>
>>>>
>>>>
>>>> 1. If I uncomment the finalizeTests() method, the error starts.
>>>>
>>>> 2. If I uncomment resultClient3, resultClient4 it might start working,
>>>> then
>>>> randomly it will show up again and I have to comment them out in order
>>>> for
>>>> the test to pass again.
>>>>
>>>>
>>>> Is there some bug/defect in the Mock that I have not googled?
>>>>
>>>>
>>>>
>>>> ---
>>>> 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
>>>> ---
>>>>
>>>>
>>>
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
I have tried everything I can at least 20 times. I really appreciate the
help on this one as there is no pattern for me to follow to solve this.
Sometimes it works, and sometimes it doesn't.

I also tried this in the route (none successful):


from("activemq:Consumer.1.VirtualTopic.Table.1").wireTap("mock://resultAllClients").to("mock:resultClient1");

        from("seda:resultClient1").to("mock:resultClient1");

        from("seda:resultClient2").to("mock:resultClient2");


Is there any advise anyone can give me to understand a better way to DEBUG
through the routes and 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 Sun, Aug 23, 2009 at 5:09 AM, Mick Knutson <mk...@baselogic.com>wrote:

> Here is the 1 Route file I have:
>
>     @Override
>     public void configure() throws Exception {
>         log.info("//@@@@@ CLIENT ROUTES
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//");
>
>
> //from("activemq:Consumer.1.VirtualTopic.Table.1").wireTap("mock://resultAllClients").to("mock:resultClient1");
>
>
> from("seda:resultClient1").wireTap("mock://resultAllClients").to("mock:resultClient1");
>
> from("seda:resultClient2").wireTap("mock://resultAllClients").to("mock:resultClient2");
>
> from("seda:resultClient3").wireTap("mock://resultAllClients").to("mock:resultClient3");
>
> from("seda:resultClient4").wireTap("mock://resultAllClients").to("mock:resultClient4");
>
> from("seda:resultClient5").wireTap("mock://resultAllClients").to("mock:resultClient5");
>
> from("seda:resultClient6").wireTap("mock://resultAllClients").to("mock:resultClient6");
>
> from("seda:resultClient7").wireTap("mock://resultAllClients").to("mock:resultClient7");
>
> from("seda:resultClient8").wireTap("mock://resultAllClients").to("mock:resultClient8");
>
> from("seda:resultClient9").wireTap("mock://resultAllClients").to("mock:resultClient9");
>
> from("seda:resultClient10").wireTap("mock://resultAllClients").to("mock:resultClient10");
>
> from("seda:resultClient11").wireTap("mock://resultAllClients").to("mock:resultClient11");
>
>     } // end configure
>
>
> ---
> 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 Sun, Aug 23, 2009 at 3:14 AM, Willem Jiang <wi...@gmail.com>wrote:
>
>> Hi Mick,
>>
>> Can you show me the route rule ?
>> It will help us to trace the issue :)
>>
>> Willem
>>
>>
>> Mick Knutson wrote:
>>
>>> I have a unit test that has a wiretap that routes the message to a mock
>>> endpoint.
>>> Here is what works:
>>>
>>>    @EndpointInject(uri = "mock:resultAllClients")
>>>    protected MockEndpoint resultAllClients;
>>>
>>>    @EndpointInject(uri = "mock:resultClient1")
>>>    protected MockEndpoint resultClient1;
>>>    @EndpointInject(uri = "mock:resultClient2")
>>>    protected MockEndpoint resultClient2;
>>>    @EndpointInject(uri = "mock:resultClient3")
>>>    protected MockEndpoint resultClient3;
>>>    @EndpointInject(uri = "mock:resultClient4")
>>>    protected MockEndpoint resultClient4;
>>>
>>>    @Test
>>>    public void testSendBetMessage() throws Exception {
>>>        log.info("Send a test message to Table Service");
>>>
>>>        //resultAllClients.expectedMinimumMessageCount(3);
>>>        resultClient1.expectedMessageCount(1);
>>>        resultClient2.expectedMessageCount(1);
>>>        //resultClient3.expectedMessageCount(1);
>>>        //resultClient4.expectedMessageCount(1);
>>>
>>>
>>>        // Send the test message to make Server Service create our Status
>>> Message
>>>        producerTemplate.sendBody("jms:queue:bets",
>>>                ExchangePattern.InOnly, 22);
>>>
>>>        // now lets assert that the mock endpoint received messages
>>>        resultClient1.assertIsSatisfied();
>>>        resultClient2.assertIsSatisfied();
>>>        //resultClient3.assertIsSatisfied();
>>>        //resultClient4.assertIsSatisfied();
>>>
>>>        //resultAllClients.assertIsSatisfied();
>>>        log.info("XXXXXXXXXX DONE
>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>>
>>>    }
>>>
>>>    /*@After
>>>    public void finalizeTests() {
>>>        // resultAllClients.reset();
>>>        resultClient1.reset();
>>>        resultClient2.reset();
>>>        resultClient3.reset();
>>>        // resultClient4.reset();
>>>    }*/
>>>
>>>
>>>
>>> This is in 1 unit test class and the way it is above has all assertions
>>> pass.
>>> If any of the following things change, I get:
>>>
>>> java.lang.AssertionError: mock://resultClient1 Received message count.
>>> Expected: <1> but was: <0>
>>>
>>>
>>> 1. If I uncomment the finalizeTests() method, the error starts.
>>>
>>> 2. If I uncomment resultClient3, resultClient4 it might start working,
>>> then
>>> randomly it will show up again and I have to comment them out in order
>>> for
>>> the test to pass again.
>>>
>>>
>>> Is there some bug/defect in the Mock that I have not googled?
>>>
>>>
>>>
>>> ---
>>> 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: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
Here is the 1 Route file I have:

    @Override
    public void configure() throws Exception {
        log.info("//@@@@@ CLIENT ROUTES
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@//");


//from("activemq:Consumer.1.VirtualTopic.Table.1").wireTap("mock://resultAllClients").to("mock:resultClient1");


from("seda:resultClient1").wireTap("mock://resultAllClients").to("mock:resultClient1");

from("seda:resultClient2").wireTap("mock://resultAllClients").to("mock:resultClient2");

from("seda:resultClient3").wireTap("mock://resultAllClients").to("mock:resultClient3");

from("seda:resultClient4").wireTap("mock://resultAllClients").to("mock:resultClient4");

from("seda:resultClient5").wireTap("mock://resultAllClients").to("mock:resultClient5");

from("seda:resultClient6").wireTap("mock://resultAllClients").to("mock:resultClient6");

from("seda:resultClient7").wireTap("mock://resultAllClients").to("mock:resultClient7");

from("seda:resultClient8").wireTap("mock://resultAllClients").to("mock:resultClient8");

from("seda:resultClient9").wireTap("mock://resultAllClients").to("mock:resultClient9");

from("seda:resultClient10").wireTap("mock://resultAllClients").to("mock:resultClient10");

from("seda:resultClient11").wireTap("mock://resultAllClients").to("mock:resultClient11");

    } // end configure


---
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 Sun, Aug 23, 2009 at 3:14 AM, Willem Jiang <wi...@gmail.com>wrote:

> Hi Mick,
>
> Can you show me the route rule ?
> It will help us to trace the issue :)
>
> Willem
>
>
> Mick Knutson wrote:
>
>> I have a unit test that has a wiretap that routes the message to a mock
>> endpoint.
>> Here is what works:
>>
>>    @EndpointInject(uri = "mock:resultAllClients")
>>    protected MockEndpoint resultAllClients;
>>
>>    @EndpointInject(uri = "mock:resultClient1")
>>    protected MockEndpoint resultClient1;
>>    @EndpointInject(uri = "mock:resultClient2")
>>    protected MockEndpoint resultClient2;
>>    @EndpointInject(uri = "mock:resultClient3")
>>    protected MockEndpoint resultClient3;
>>    @EndpointInject(uri = "mock:resultClient4")
>>    protected MockEndpoint resultClient4;
>>
>>    @Test
>>    public void testSendBetMessage() throws Exception {
>>        log.info("Send a test message to Table Service");
>>
>>        //resultAllClients.expectedMinimumMessageCount(3);
>>        resultClient1.expectedMessageCount(1);
>>        resultClient2.expectedMessageCount(1);
>>        //resultClient3.expectedMessageCount(1);
>>        //resultClient4.expectedMessageCount(1);
>>
>>
>>        // Send the test message to make Server Service create our Status
>> Message
>>        producerTemplate.sendBody("jms:queue:bets",
>>                ExchangePattern.InOnly, 22);
>>
>>        // now lets assert that the mock endpoint received messages
>>        resultClient1.assertIsSatisfied();
>>        resultClient2.assertIsSatisfied();
>>        //resultClient3.assertIsSatisfied();
>>        //resultClient4.assertIsSatisfied();
>>
>>        //resultAllClients.assertIsSatisfied();
>>        log.info("XXXXXXXXXX DONE
>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>
>>    }
>>
>>    /*@After
>>    public void finalizeTests() {
>>        // resultAllClients.reset();
>>        resultClient1.reset();
>>        resultClient2.reset();
>>        resultClient3.reset();
>>        // resultClient4.reset();
>>    }*/
>>
>>
>>
>> This is in 1 unit test class and the way it is above has all assertions
>> pass.
>> If any of the following things change, I get:
>>
>> java.lang.AssertionError: mock://resultClient1 Received message count.
>> Expected: <1> but was: <0>
>>
>>
>> 1. If I uncomment the finalizeTests() method, the error starts.
>>
>> 2. If I uncomment resultClient3, resultClient4 it might start working,
>> then
>> randomly it will show up again and I have to comment them out in order for
>> the test to pass again.
>>
>>
>> Is there some bug/defect in the Mock that I have not googled?
>>
>>
>>
>> ---
>> 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: frustration with multiple mock endpoints in 1 unit test.

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

Can you show me the route rule ?
It will help us to trace the issue :)

Willem

Mick Knutson wrote:
> I have a unit test that has a wiretap that routes the message to a mock
> endpoint.
> Here is what works:
> 
>     @EndpointInject(uri = "mock:resultAllClients")
>     protected MockEndpoint resultAllClients;
> 
>     @EndpointInject(uri = "mock:resultClient1")
>     protected MockEndpoint resultClient1;
>     @EndpointInject(uri = "mock:resultClient2")
>     protected MockEndpoint resultClient2;
>     @EndpointInject(uri = "mock:resultClient3")
>     protected MockEndpoint resultClient3;
>     @EndpointInject(uri = "mock:resultClient4")
>     protected MockEndpoint resultClient4;
> 
>     @Test
>     public void testSendBetMessage() throws Exception {
>         log.info("Send a test message to Table Service");
> 
>         //resultAllClients.expectedMinimumMessageCount(3);
>         resultClient1.expectedMessageCount(1);
>         resultClient2.expectedMessageCount(1);
>         //resultClient3.expectedMessageCount(1);
>         //resultClient4.expectedMessageCount(1);
> 
> 
>         // Send the test message to make Server Service create our Status
> Message
>         producerTemplate.sendBody("jms:queue:bets",
>                 ExchangePattern.InOnly, 22);
> 
>         // now lets assert that the mock endpoint received messages
>         resultClient1.assertIsSatisfied();
>         resultClient2.assertIsSatisfied();
>         //resultClient3.assertIsSatisfied();
>         //resultClient4.assertIsSatisfied();
> 
>         //resultAllClients.assertIsSatisfied();
>         log.info("XXXXXXXXXX DONE
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> 
>     }
> 
>     /*@After
>     public void finalizeTests() {
>         // resultAllClients.reset();
>         resultClient1.reset();
>         resultClient2.reset();
>         resultClient3.reset();
>         // resultClient4.reset();
>     }*/
> 
> 
> 
> This is in 1 unit test class and the way it is above has all assertions
> pass.
> If any of the following things change, I get:
> 
> java.lang.AssertionError: mock://resultClient1 Received message count.
> Expected: <1> but was: <0>
> 
> 
> 1. If I uncomment the finalizeTests() method, the error starts.
> 
> 2. If I uncomment resultClient3, resultClient4 it might start working, then
> randomly it will show up again and I have to comment them out in order for
> the test to pass again.
> 
> 
> Is there some bug/defect in the Mock that I have not googled?
> 
> 
> 
> ---
> 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: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
I  have been asking opinions here about how to solve this issue, which is
where I came up with this.

I need each consumer to get a copy of the message. I assumed that Virtual
Topics are Durable right?

The reason I use AOP, is to be able to test. I looked at the AMQ
VirtualTopic test, but that was not going to use MDP's as suggested. So I
was unable to use that test as a model. But AOP seemed straight forward in
that I just created a wiretap of sorts.

I guess my confusion is that from the stack, it appears that all components
involved get a message except the Mock. The MDP, then the AOP Processor,
then the seda queue, then the inline Route Processor, and I assume when the
Route Processor completes, then the message is automatically routed to the
next ".to(mock:xyz)" which is my Mock Client.

So, besides the Tracer() you mentioned (thanks btw), is there anything else
that might help me to maybe debug walk through that next ".to(mock:xyz)"
forward?


---
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 Wed, Aug 26, 2009 at 8:16 AM, Claus Ibsen <cl...@gmail.com> wrote:

> On Tue, Aug 25, 2009 at 7:41 PM, Mick Knutson<mk...@baselogic.com>
> wrote:
> > I started to create a blog to talk about what I am trying to do. I also
> talk
> > about the current issues I have for testing.
> >
> >
> http://www.baselogic.com/blog/java/testing-activemq-virtualtopics-using-camel-and-junit
> >
> >
>
> Nice blog.
>
> Anyway I will suggest to start simple and do not use AOP, spring
> testing etc. to get a simple test working as you want.
> Then grow from there.
>
> And are you sure that the virtual topic works as you want, sounds as
> if there are competing consumers. Are the topic durable so you are
> guaranteed that every subscriber gets a copy?
>
> Maybe try a test without this virtual topic and try with a regular
> durable topic and / or a few queues to get the hang on it.
>
>
> >
> > ---
> > 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 24, 2009 at 9:47 AM, Mick Knutson <mknutson@baselogic.com
> >wrote:
> >
> >> I appreciate your observation, as all too often the net is, and can be
> >> misinterpreted. Again, please accept my apology.
> >>
> >> I am currently writing something more formal, that I will be able to use
> >> now, and going forward, and again, I respectfully appreciate everyone's
> help
> >> and time.
> >>
> >> ---
> >> 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 24, 2009 at 9:40 AM, Claus Ibsen <claus.ibsen@gmail.com
> >wrote:
> >>
> >>> Hi
> >>>
> >>> Thanks for understanding.
> >>>
> >>> And I may have been a bit harsh but its just to easy to write and
> >>> press the send button :)
> >>> Lets start over when we got a better understanding what you want to do
> >>> so we can give better advice.
> >>>
> >>> And btw I am not a moderator or hold any special privileges or
> >>> anything at this mailinglist.
> >>> What I did write was my personal observations.
> >>>
> >>>
> >>> On Mon, Aug 24, 2009 at 3:04 PM, Mick Knutson<mk...@baselogic.com>
> >>> wrote:
> >>> > 1. I am going to create a blog as I promised, and I am going to start
> >>> > writing it this minute to help describe the entire picture and all
> the
> >>> piece
> >>> > involved. Sorry I have not done this before.
> >>> >
> >>> > 2. I feel incredibly _bad_ that I have ever come across as yelling
> >>> > _ever_.... I would have never consciously done so, and am extremely
> >>> grateful
> >>> > for your help. Again, very, very sorry...
> >>> >
> >>> >
> >>> >
> >>> > ---
> >>> > 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 24, 2009 at 3:20 AM, Claus Ibsen <cl...@gmail.com>
> >>> wrote:
> >>> >
> >>> >> Hi
> >>> >>
> >>> >> Maybe you should start over and explain to us what you want to test?
> >>> >>
> >>> >> Its not easy / motivating to help when people shout and post all
> kind
> >>> >> of code and expecting the community to use time / take time to dig
> >>> >> into a haystack.
> >>> >> Sorry I could not resist stating this.
> >>> >>
> >>> >> So I suggest to start easy and create a small unit test and maybe
> >>> >> instead of JMS try out with pure seda to get the hang of the mock
> >>> >> endpoints and how to use them. Then later write unit tests based on
> >>> >> JMS.
> >>> >>
> >>> >>
> >>> >>
> >>> >>
> >>> >> On Mon, Aug 24, 2009 at 8:55 AM, Willem Jiang<
> willem.jiang@gmail.com>
> >>> >> wrote:
> >>> >> > Hi
> >>> >> >
> >>> >> > I still don't know how do you send the message to
> >>> "seda:resultClient1",
> >>> >> > "seda:resultClient2" etc.
> >>> >> > BTW
> >>> >> >
> >>> >> > "seda:resultClient1" is not the same endpoint of
> "mock:resultClient1"
> >>> >> >
> >>> >> > Willem
> >>> >> > Mick Knutson wrote:
> >>> >> >>
> >>> >> >> There is only 1 test right now, but I added:
> >>> >> >>
> >>> >> >>    @Before
> >>> >> >>    public void testBefore() throws Exception {
> >>> >> >>        log.info("*** Before ***");
> >>> >> >>        //assertNotNull(context);
> >>> >> >>
> >>> >> >>        resultClient1.reset();
> >>> >> >>        resultClient2.reset();
> >>> >> >>        resultClient3.reset();
> >>> >> >>        resultClient4.reset();
> >>> >> >>        //resultAllClients.reset();
> >>> >> >>    }
> >>> >> >>
> >>> >> >> already. But I sent another mail a second ago about the tracer.
> >>> >> >>
> >>> >> >> The strange issue is not getting too many message, but the FIRST
> >>> mock
> >>> >> just
> >>> >> >> not getting any messages.
> >>> >> >>
> >>> >> >> I have even played with commenting out client 1, then I get
> client 2
> >>> >> stops
> >>> >> >> getting message randomly. I say randomly, because I have had the
> >>> test
> >>> >> >> working, then I change nothing. But I try to run through 10+
> >>> iterations
> >>> >> >> through the same test. It will work for several, then just stop.
> >>> Then it
> >>> >> >> might start again. if I keep going, but most of the time not.
> >>> >> >>
> >>> >> >> I am looking for a pattern to deduce the issue, but it is
> alluding
> >>> me.
> >>> >> >>
> >>> >> >>
> >>> >> >>
> >>> >> >> ---
> >>> >> >> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang
> >>> >> >> <wi...@gmail.com>wrote:
> >>> >> >>
> >>> >> >>> Mick Knutson wrote:
> >>> >> >>>
> >>> >> >>>> I have a unit test that has a wiretap that routes the message
> to a
> >>> >> mock
> >>> >> >>>> endpoint.
> >>> >> >>>> Here is what works:
> >>> >> >>>>
> >>> >> >>>>   @EndpointInject(uri = "mock:resultAllClients")
> >>> >> >>>>   protected MockEndpoint resultAllClients;
> >>> >> >>>>
> >>> >> >>>>   @EndpointInject(uri = "mock:resultClient1")
> >>> >> >>>>   protected MockEndpoint resultClient1;
> >>> >> >>>>   @EndpointInject(uri = "mock:resultClient2")
> >>> >> >>>>   protected MockEndpoint resultClient2;
> >>> >> >>>>   @EndpointInject(uri = "mock:resultClient3")
> >>> >> >>>>   protected MockEndpoint resultClient3;
> >>> >> >>>>   @EndpointInject(uri = "mock:resultClient4")
> >>> >> >>>>   protected MockEndpoint resultClient4;
> >>> >> >>>>
> >>> >> >>>>   @Test
> >>> >> >>>>   public void testSendBetMessage() throws Exception {
> >>> >> >>>>       log.info("Send a test message to Table Service");
> >>> >> >>>>
> >>> >> >>>>       //resultAllClients.expectedMinimumMessageCount(3);
> >>> >> >>>>       resultClient1.expectedMessageCount(1);
> >>> >> >>>>       resultClient2.expectedMessageCount(1);
> >>> >> >>>>       //resultClient3.expectedMessageCount(1);
> >>> >> >>>>       //resultClient4.expectedMessageCount(1);
> >>> >> >>>>
> >>> >> >>>>
> >>> >> >>>>       // Send the test message to make Server Service create
> our
> >>> >> Status
> >>> >> >>>> Message
> >>> >> >>>>       producerTemplate.sendBody("jms:queue:bets",
> >>> >> >>>>               ExchangePattern.InOnly, 22);
> >>> >> >>>>
> >>> >> >>>>       // now lets assert that the mock endpoint received
> messages
> >>> >> >>>>       resultClient1.assertIsSatisfied();
> >>> >> >>>>       resultClient2.assertIsSatisfied();
> >>> >> >>>>       //resultClient3.assertIsSatisfied();
> >>> >> >>>>       //resultClient4.assertIsSatisfied();
> >>> >> >>>>
> >>> >> >>>>       //resultAllClients.assertIsSatisfied();
> >>> >> >>>>       log.info("XXXXXXXXXX DONE
> >>> >> >>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> >>> >> >>>>
> >>> >> >>>>   }
> >>> >> >>>>
> >>> >> >>>>   /*@After
> >>> >> >>>>   public void finalizeTests() {
> >>> >> >>>>       // resultAllClients.reset();
> >>> >> >>>>       resultClient1.reset();
> >>> >> >>>>       resultClient2.reset();
> >>> >> >>>>       resultClient3.reset();
> >>> >> >>>>       // resultClient4.reset();
> >>> >> >>>>   }*/
> >>> >> >>>>
> >>> >> >>>>
> >>> >> >>>>
> >>> >> >>>> This is in 1 unit test class and the way it is above has all
> >>> >> assertions
> >>> >> >>>> pass.
> >>> >> >>>> If any of the following things change, I get:
> >>> >> >>>>
> >>> >> >>>> java.lang.AssertionError: mock://resultClient1 Received message
> >>> count.
> >>> >> >>>> Expected: <1> but was: <0>
> >>> >> >>>>
> >>> >> >>>>
> >>> >> >>>> 1. If I uncomment the finalizeTests() method, the error starts.
> >>> >> >>>>
> >>> >> >>> Since the mock endpoints are injected into your unit test, if
> there
> >>> are
> >>> >> >>> more than one unit test method , you need to reset the mock
> >>> endpoints
> >>> >> to
> >>> >> >>> make sure the message count values are right.
> >>> >> >>>
> >>> >> >>>
> >>> >> >>>> 2. If I uncomment resultClient3, resultClient4 it might start
> >>> working,
> >>> >> >>>> then
> >>> >> >>>> randomly it will show up again and I have to comment them out
> in
> >>> order
> >>> >> >>>> for
> >>> >> >>>> the test to pass again.
> >>> >> >>>>
> >>> >> >>> I don't know how your mock:resultClient3, mock:resultClient4 can
> >>> >> receive
> >>> >> >>> the message from the route file that you showed me.
> >>> >> >>>
> >>> >> >>>
> >>> >> >>>
> >>> >> >>>> Is there some bug/defect in the Mock that I have not googled?
> >>> >> >>>>
> >>> >> >>>>
> >>> >> >>>>
> >>> >> >>>> ---
> >>> >> >>>> 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
> >>> >> >>>> ---
> >>> >> >>>>
> >>> >> >>>>
> >>> >> >>> Willem
> >>> >> >>>
> >>> >> >>
> >>> >> >
> >>> >> >
> >>> >>
> >>> >>
> >>> >>
> >>> >> --
> >>> >> Claus Ibsen
> >>> >> Apache Camel Committer
> >>> >>
> >>> >> Open Source Integration: http://fusesource.com
> >>> >> Blog: http://davsclaus.blogspot.com/
> >>> >> Twitter: http://twitter.com/davsclaus
> >>> >>
> >>> >
> >>>
> >>>
> >>>
> >>> --
> >>> Claus Ibsen
> >>> Apache Camel Committer
> >>>
> >>> Open Source Integration: http://fusesource.com
> >>> Blog: http://davsclaus.blogspot.com/
> >>> Twitter: http://twitter.com/davsclaus
> >>>
> >>
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Aug 25, 2009 at 7:41 PM, Mick Knutson<mk...@baselogic.com> wrote:
> I started to create a blog to talk about what I am trying to do. I also talk
> about the current issues I have for testing.
>
> http://www.baselogic.com/blog/java/testing-activemq-virtualtopics-using-camel-and-junit
>
>

Nice blog.

Anyway I will suggest to start simple and do not use AOP, spring
testing etc. to get a simple test working as you want.
Then grow from there.

And are you sure that the virtual topic works as you want, sounds as
if there are competing consumers. Are the topic durable so you are
guaranteed that every subscriber gets a copy?

Maybe try a test without this virtual topic and try with a regular
durable topic and / or a few queues to get the hang on it.


>
> ---
> 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 24, 2009 at 9:47 AM, Mick Knutson <mk...@baselogic.com>wrote:
>
>> I appreciate your observation, as all too often the net is, and can be
>> misinterpreted. Again, please accept my apology.
>>
>> I am currently writing something more formal, that I will be able to use
>> now, and going forward, and again, I respectfully appreciate everyone's help
>> and time.
>>
>> ---
>> 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 24, 2009 at 9:40 AM, Claus Ibsen <cl...@gmail.com>wrote:
>>
>>> Hi
>>>
>>> Thanks for understanding.
>>>
>>> And I may have been a bit harsh but its just to easy to write and
>>> press the send button :)
>>> Lets start over when we got a better understanding what you want to do
>>> so we can give better advice.
>>>
>>> And btw I am not a moderator or hold any special privileges or
>>> anything at this mailinglist.
>>> What I did write was my personal observations.
>>>
>>>
>>> On Mon, Aug 24, 2009 at 3:04 PM, Mick Knutson<mk...@baselogic.com>
>>> wrote:
>>> > 1. I am going to create a blog as I promised, and I am going to start
>>> > writing it this minute to help describe the entire picture and all the
>>> piece
>>> > involved. Sorry I have not done this before.
>>> >
>>> > 2. I feel incredibly _bad_ that I have ever come across as yelling
>>> > _ever_.... I would have never consciously done so, and am extremely
>>> grateful
>>> > for your help. Again, very, very sorry...
>>> >
>>> >
>>> >
>>> > ---
>>> > 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 24, 2009 at 3:20 AM, Claus Ibsen <cl...@gmail.com>
>>> wrote:
>>> >
>>> >> Hi
>>> >>
>>> >> Maybe you should start over and explain to us what you want to test?
>>> >>
>>> >> Its not easy / motivating to help when people shout and post all kind
>>> >> of code and expecting the community to use time / take time to dig
>>> >> into a haystack.
>>> >> Sorry I could not resist stating this.
>>> >>
>>> >> So I suggest to start easy and create a small unit test and maybe
>>> >> instead of JMS try out with pure seda to get the hang of the mock
>>> >> endpoints and how to use them. Then later write unit tests based on
>>> >> JMS.
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> On Mon, Aug 24, 2009 at 8:55 AM, Willem Jiang<wi...@gmail.com>
>>> >> wrote:
>>> >> > Hi
>>> >> >
>>> >> > I still don't know how do you send the message to
>>> "seda:resultClient1",
>>> >> > "seda:resultClient2" etc.
>>> >> > BTW
>>> >> >
>>> >> > "seda:resultClient1" is not the same endpoint of "mock:resultClient1"
>>> >> >
>>> >> > Willem
>>> >> > Mick Knutson wrote:
>>> >> >>
>>> >> >> There is only 1 test right now, but I added:
>>> >> >>
>>> >> >>    @Before
>>> >> >>    public void testBefore() throws Exception {
>>> >> >>        log.info("*** Before ***");
>>> >> >>        //assertNotNull(context);
>>> >> >>
>>> >> >>        resultClient1.reset();
>>> >> >>        resultClient2.reset();
>>> >> >>        resultClient3.reset();
>>> >> >>        resultClient4.reset();
>>> >> >>        //resultAllClients.reset();
>>> >> >>    }
>>> >> >>
>>> >> >> already. But I sent another mail a second ago about the tracer.
>>> >> >>
>>> >> >> The strange issue is not getting too many message, but the FIRST
>>> mock
>>> >> just
>>> >> >> not getting any messages.
>>> >> >>
>>> >> >> I have even played with commenting out client 1, then I get client 2
>>> >> stops
>>> >> >> getting message randomly. I say randomly, because I have had the
>>> test
>>> >> >> working, then I change nothing. But I try to run through 10+
>>> iterations
>>> >> >> through the same test. It will work for several, then just stop.
>>> Then it
>>> >> >> might start again. if I keep going, but most of the time not.
>>> >> >>
>>> >> >> I am looking for a pattern to deduce the issue, but it is alluding
>>> me.
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> ---
>>> >> >> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang
>>> >> >> <wi...@gmail.com>wrote:
>>> >> >>
>>> >> >>> Mick Knutson wrote:
>>> >> >>>
>>> >> >>>> I have a unit test that has a wiretap that routes the message to a
>>> >> mock
>>> >> >>>> endpoint.
>>> >> >>>> Here is what works:
>>> >> >>>>
>>> >> >>>>   @EndpointInject(uri = "mock:resultAllClients")
>>> >> >>>>   protected MockEndpoint resultAllClients;
>>> >> >>>>
>>> >> >>>>   @EndpointInject(uri = "mock:resultClient1")
>>> >> >>>>   protected MockEndpoint resultClient1;
>>> >> >>>>   @EndpointInject(uri = "mock:resultClient2")
>>> >> >>>>   protected MockEndpoint resultClient2;
>>> >> >>>>   @EndpointInject(uri = "mock:resultClient3")
>>> >> >>>>   protected MockEndpoint resultClient3;
>>> >> >>>>   @EndpointInject(uri = "mock:resultClient4")
>>> >> >>>>   protected MockEndpoint resultClient4;
>>> >> >>>>
>>> >> >>>>   @Test
>>> >> >>>>   public void testSendBetMessage() throws Exception {
>>> >> >>>>       log.info("Send a test message to Table Service");
>>> >> >>>>
>>> >> >>>>       //resultAllClients.expectedMinimumMessageCount(3);
>>> >> >>>>       resultClient1.expectedMessageCount(1);
>>> >> >>>>       resultClient2.expectedMessageCount(1);
>>> >> >>>>       //resultClient3.expectedMessageCount(1);
>>> >> >>>>       //resultClient4.expectedMessageCount(1);
>>> >> >>>>
>>> >> >>>>
>>> >> >>>>       // Send the test message to make Server Service create our
>>> >> Status
>>> >> >>>> Message
>>> >> >>>>       producerTemplate.sendBody("jms:queue:bets",
>>> >> >>>>               ExchangePattern.InOnly, 22);
>>> >> >>>>
>>> >> >>>>       // now lets assert that the mock endpoint received messages
>>> >> >>>>       resultClient1.assertIsSatisfied();
>>> >> >>>>       resultClient2.assertIsSatisfied();
>>> >> >>>>       //resultClient3.assertIsSatisfied();
>>> >> >>>>       //resultClient4.assertIsSatisfied();
>>> >> >>>>
>>> >> >>>>       //resultAllClients.assertIsSatisfied();
>>> >> >>>>       log.info("XXXXXXXXXX DONE
>>> >> >>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>> >> >>>>
>>> >> >>>>   }
>>> >> >>>>
>>> >> >>>>   /*@After
>>> >> >>>>   public void finalizeTests() {
>>> >> >>>>       // resultAllClients.reset();
>>> >> >>>>       resultClient1.reset();
>>> >> >>>>       resultClient2.reset();
>>> >> >>>>       resultClient3.reset();
>>> >> >>>>       // resultClient4.reset();
>>> >> >>>>   }*/
>>> >> >>>>
>>> >> >>>>
>>> >> >>>>
>>> >> >>>> This is in 1 unit test class and the way it is above has all
>>> >> assertions
>>> >> >>>> pass.
>>> >> >>>> If any of the following things change, I get:
>>> >> >>>>
>>> >> >>>> java.lang.AssertionError: mock://resultClient1 Received message
>>> count.
>>> >> >>>> Expected: <1> but was: <0>
>>> >> >>>>
>>> >> >>>>
>>> >> >>>> 1. If I uncomment the finalizeTests() method, the error starts.
>>> >> >>>>
>>> >> >>> Since the mock endpoints are injected into your unit test, if there
>>> are
>>> >> >>> more than one unit test method , you need to reset the mock
>>> endpoints
>>> >> to
>>> >> >>> make sure the message count values are right.
>>> >> >>>
>>> >> >>>
>>> >> >>>> 2. If I uncomment resultClient3, resultClient4 it might start
>>> working,
>>> >> >>>> then
>>> >> >>>> randomly it will show up again and I have to comment them out in
>>> order
>>> >> >>>> for
>>> >> >>>> the test to pass again.
>>> >> >>>>
>>> >> >>> I don't know how your mock:resultClient3, mock:resultClient4 can
>>> >> receive
>>> >> >>> the message from the route file that you showed me.
>>> >> >>>
>>> >> >>>
>>> >> >>>
>>> >> >>>> Is there some bug/defect in the Mock that I have not googled?
>>> >> >>>>
>>> >> >>>>
>>> >> >>>>
>>> >> >>>> ---
>>> >> >>>> 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
>>> >> >>>> ---
>>> >> >>>>
>>> >> >>>>
>>> >> >>> Willem
>>> >> >>>
>>> >> >>
>>> >> >
>>> >> >
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Claus Ibsen
>>> >> Apache Camel Committer
>>> >>
>>> >> Open Source Integration: http://fusesource.com
>>> >> Blog: http://davsclaus.blogspot.com/
>>> >> Twitter: http://twitter.com/davsclaus
>>> >>
>>> >
>>>
>>>
>>>
>>> --
>>> Claus Ibsen
>>> Apache Camel Committer
>>>
>>> Open Source Integration: http://fusesource.com
>>> Blog: http://davsclaus.blogspot.com/
>>> Twitter: http://twitter.com/davsclaus
>>>
>>
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
I started to create a blog to talk about what I am trying to do. I also talk
about the current issues I have for testing.

http://www.baselogic.com/blog/java/testing-activemq-virtualtopics-using-camel-and-junit



---
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 24, 2009 at 9:47 AM, Mick Knutson <mk...@baselogic.com>wrote:

> I appreciate your observation, as all too often the net is, and can be
> misinterpreted. Again, please accept my apology.
>
> I am currently writing something more formal, that I will be able to use
> now, and going forward, and again, I respectfully appreciate everyone's help
> and time.
>
> ---
> 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 24, 2009 at 9:40 AM, Claus Ibsen <cl...@gmail.com>wrote:
>
>> Hi
>>
>> Thanks for understanding.
>>
>> And I may have been a bit harsh but its just to easy to write and
>> press the send button :)
>> Lets start over when we got a better understanding what you want to do
>> so we can give better advice.
>>
>> And btw I am not a moderator or hold any special privileges or
>> anything at this mailinglist.
>> What I did write was my personal observations.
>>
>>
>> On Mon, Aug 24, 2009 at 3:04 PM, Mick Knutson<mk...@baselogic.com>
>> wrote:
>> > 1. I am going to create a blog as I promised, and I am going to start
>> > writing it this minute to help describe the entire picture and all the
>> piece
>> > involved. Sorry I have not done this before.
>> >
>> > 2. I feel incredibly _bad_ that I have ever come across as yelling
>> > _ever_.... I would have never consciously done so, and am extremely
>> grateful
>> > for your help. Again, very, very sorry...
>> >
>> >
>> >
>> > ---
>> > 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 24, 2009 at 3:20 AM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >> Hi
>> >>
>> >> Maybe you should start over and explain to us what you want to test?
>> >>
>> >> Its not easy / motivating to help when people shout and post all kind
>> >> of code and expecting the community to use time / take time to dig
>> >> into a haystack.
>> >> Sorry I could not resist stating this.
>> >>
>> >> So I suggest to start easy and create a small unit test and maybe
>> >> instead of JMS try out with pure seda to get the hang of the mock
>> >> endpoints and how to use them. Then later write unit tests based on
>> >> JMS.
>> >>
>> >>
>> >>
>> >>
>> >> On Mon, Aug 24, 2009 at 8:55 AM, Willem Jiang<wi...@gmail.com>
>> >> wrote:
>> >> > Hi
>> >> >
>> >> > I still don't know how do you send the message to
>> "seda:resultClient1",
>> >> > "seda:resultClient2" etc.
>> >> > BTW
>> >> >
>> >> > "seda:resultClient1" is not the same endpoint of "mock:resultClient1"
>> >> >
>> >> > Willem
>> >> > Mick Knutson wrote:
>> >> >>
>> >> >> There is only 1 test right now, but I added:
>> >> >>
>> >> >>    @Before
>> >> >>    public void testBefore() throws Exception {
>> >> >>        log.info("*** Before ***");
>> >> >>        //assertNotNull(context);
>> >> >>
>> >> >>        resultClient1.reset();
>> >> >>        resultClient2.reset();
>> >> >>        resultClient3.reset();
>> >> >>        resultClient4.reset();
>> >> >>        //resultAllClients.reset();
>> >> >>    }
>> >> >>
>> >> >> already. But I sent another mail a second ago about the tracer.
>> >> >>
>> >> >> The strange issue is not getting too many message, but the FIRST
>> mock
>> >> just
>> >> >> not getting any messages.
>> >> >>
>> >> >> I have even played with commenting out client 1, then I get client 2
>> >> stops
>> >> >> getting message randomly. I say randomly, because I have had the
>> test
>> >> >> working, then I change nothing. But I try to run through 10+
>> iterations
>> >> >> through the same test. It will work for several, then just stop.
>> Then it
>> >> >> might start again. if I keep going, but most of the time not.
>> >> >>
>> >> >> I am looking for a pattern to deduce the issue, but it is alluding
>> me.
>> >> >>
>> >> >>
>> >> >>
>> >> >> ---
>> >> >> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang
>> >> >> <wi...@gmail.com>wrote:
>> >> >>
>> >> >>> Mick Knutson wrote:
>> >> >>>
>> >> >>>> I have a unit test that has a wiretap that routes the message to a
>> >> mock
>> >> >>>> endpoint.
>> >> >>>> Here is what works:
>> >> >>>>
>> >> >>>>   @EndpointInject(uri = "mock:resultAllClients")
>> >> >>>>   protected MockEndpoint resultAllClients;
>> >> >>>>
>> >> >>>>   @EndpointInject(uri = "mock:resultClient1")
>> >> >>>>   protected MockEndpoint resultClient1;
>> >> >>>>   @EndpointInject(uri = "mock:resultClient2")
>> >> >>>>   protected MockEndpoint resultClient2;
>> >> >>>>   @EndpointInject(uri = "mock:resultClient3")
>> >> >>>>   protected MockEndpoint resultClient3;
>> >> >>>>   @EndpointInject(uri = "mock:resultClient4")
>> >> >>>>   protected MockEndpoint resultClient4;
>> >> >>>>
>> >> >>>>   @Test
>> >> >>>>   public void testSendBetMessage() throws Exception {
>> >> >>>>       log.info("Send a test message to Table Service");
>> >> >>>>
>> >> >>>>       //resultAllClients.expectedMinimumMessageCount(3);
>> >> >>>>       resultClient1.expectedMessageCount(1);
>> >> >>>>       resultClient2.expectedMessageCount(1);
>> >> >>>>       //resultClient3.expectedMessageCount(1);
>> >> >>>>       //resultClient4.expectedMessageCount(1);
>> >> >>>>
>> >> >>>>
>> >> >>>>       // Send the test message to make Server Service create our
>> >> Status
>> >> >>>> Message
>> >> >>>>       producerTemplate.sendBody("jms:queue:bets",
>> >> >>>>               ExchangePattern.InOnly, 22);
>> >> >>>>
>> >> >>>>       // now lets assert that the mock endpoint received messages
>> >> >>>>       resultClient1.assertIsSatisfied();
>> >> >>>>       resultClient2.assertIsSatisfied();
>> >> >>>>       //resultClient3.assertIsSatisfied();
>> >> >>>>       //resultClient4.assertIsSatisfied();
>> >> >>>>
>> >> >>>>       //resultAllClients.assertIsSatisfied();
>> >> >>>>       log.info("XXXXXXXXXX DONE
>> >> >>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>> >> >>>>
>> >> >>>>   }
>> >> >>>>
>> >> >>>>   /*@After
>> >> >>>>   public void finalizeTests() {
>> >> >>>>       // resultAllClients.reset();
>> >> >>>>       resultClient1.reset();
>> >> >>>>       resultClient2.reset();
>> >> >>>>       resultClient3.reset();
>> >> >>>>       // resultClient4.reset();
>> >> >>>>   }*/
>> >> >>>>
>> >> >>>>
>> >> >>>>
>> >> >>>> This is in 1 unit test class and the way it is above has all
>> >> assertions
>> >> >>>> pass.
>> >> >>>> If any of the following things change, I get:
>> >> >>>>
>> >> >>>> java.lang.AssertionError: mock://resultClient1 Received message
>> count.
>> >> >>>> Expected: <1> but was: <0>
>> >> >>>>
>> >> >>>>
>> >> >>>> 1. If I uncomment the finalizeTests() method, the error starts.
>> >> >>>>
>> >> >>> Since the mock endpoints are injected into your unit test, if there
>> are
>> >> >>> more than one unit test method , you need to reset the mock
>> endpoints
>> >> to
>> >> >>> make sure the message count values are right.
>> >> >>>
>> >> >>>
>> >> >>>> 2. If I uncomment resultClient3, resultClient4 it might start
>> working,
>> >> >>>> then
>> >> >>>> randomly it will show up again and I have to comment them out in
>> order
>> >> >>>> for
>> >> >>>> the test to pass again.
>> >> >>>>
>> >> >>> I don't know how your mock:resultClient3, mock:resultClient4 can
>> >> receive
>> >> >>> the message from the route file that you showed me.
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>>> Is there some bug/defect in the Mock that I have not googled?
>> >> >>>>
>> >> >>>>
>> >> >>>>
>> >> >>>> ---
>> >> >>>> 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
>> >> >>>> ---
>> >> >>>>
>> >> >>>>
>> >> >>> Willem
>> >> >>>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> Apache Camel Committer
>> >>
>> >> Open Source Integration: http://fusesource.com
>> >> Blog: http://davsclaus.blogspot.com/
>> >> Twitter: http://twitter.com/davsclaus
>> >>
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>
>

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
I appreciate your observation, as all too often the net is, and can be
misinterpreted. Again, please accept my apology.

I am currently writing something more formal, that I will be able to use
now, and going forward, and again, I respectfully appreciate everyone's help
and time.

---
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 24, 2009 at 9:40 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> Thanks for understanding.
>
> And I may have been a bit harsh but its just to easy to write and
> press the send button :)
> Lets start over when we got a better understanding what you want to do
> so we can give better advice.
>
> And btw I am not a moderator or hold any special privileges or
> anything at this mailinglist.
> What I did write was my personal observations.
>
>
> On Mon, Aug 24, 2009 at 3:04 PM, Mick Knutson<mk...@baselogic.com>
> wrote:
> > 1. I am going to create a blog as I promised, and I am going to start
> > writing it this minute to help describe the entire picture and all the
> piece
> > involved. Sorry I have not done this before.
> >
> > 2. I feel incredibly _bad_ that I have ever come across as yelling
> > _ever_.... I would have never consciously done so, and am extremely
> grateful
> > for your help. Again, very, very sorry...
> >
> >
> >
> > ---
> > 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 24, 2009 at 3:20 AM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> Hi
> >>
> >> Maybe you should start over and explain to us what you want to test?
> >>
> >> Its not easy / motivating to help when people shout and post all kind
> >> of code and expecting the community to use time / take time to dig
> >> into a haystack.
> >> Sorry I could not resist stating this.
> >>
> >> So I suggest to start easy and create a small unit test and maybe
> >> instead of JMS try out with pure seda to get the hang of the mock
> >> endpoints and how to use them. Then later write unit tests based on
> >> JMS.
> >>
> >>
> >>
> >>
> >> On Mon, Aug 24, 2009 at 8:55 AM, Willem Jiang<wi...@gmail.com>
> >> wrote:
> >> > Hi
> >> >
> >> > I still don't know how do you send the message to
> "seda:resultClient1",
> >> > "seda:resultClient2" etc.
> >> > BTW
> >> >
> >> > "seda:resultClient1" is not the same endpoint of "mock:resultClient1"
> >> >
> >> > Willem
> >> > Mick Knutson wrote:
> >> >>
> >> >> There is only 1 test right now, but I added:
> >> >>
> >> >>    @Before
> >> >>    public void testBefore() throws Exception {
> >> >>        log.info("*** Before ***");
> >> >>        //assertNotNull(context);
> >> >>
> >> >>        resultClient1.reset();
> >> >>        resultClient2.reset();
> >> >>        resultClient3.reset();
> >> >>        resultClient4.reset();
> >> >>        //resultAllClients.reset();
> >> >>    }
> >> >>
> >> >> already. But I sent another mail a second ago about the tracer.
> >> >>
> >> >> The strange issue is not getting too many message, but the FIRST mock
> >> just
> >> >> not getting any messages.
> >> >>
> >> >> I have even played with commenting out client 1, then I get client 2
> >> stops
> >> >> getting message randomly. I say randomly, because I have had the test
> >> >> working, then I change nothing. But I try to run through 10+
> iterations
> >> >> through the same test. It will work for several, then just stop. Then
> it
> >> >> might start again. if I keep going, but most of the time not.
> >> >>
> >> >> I am looking for a pattern to deduce the issue, but it is alluding
> me.
> >> >>
> >> >>
> >> >>
> >> >> ---
> >> >> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang
> >> >> <wi...@gmail.com>wrote:
> >> >>
> >> >>> Mick Knutson wrote:
> >> >>>
> >> >>>> I have a unit test that has a wiretap that routes the message to a
> >> mock
> >> >>>> endpoint.
> >> >>>> Here is what works:
> >> >>>>
> >> >>>>   @EndpointInject(uri = "mock:resultAllClients")
> >> >>>>   protected MockEndpoint resultAllClients;
> >> >>>>
> >> >>>>   @EndpointInject(uri = "mock:resultClient1")
> >> >>>>   protected MockEndpoint resultClient1;
> >> >>>>   @EndpointInject(uri = "mock:resultClient2")
> >> >>>>   protected MockEndpoint resultClient2;
> >> >>>>   @EndpointInject(uri = "mock:resultClient3")
> >> >>>>   protected MockEndpoint resultClient3;
> >> >>>>   @EndpointInject(uri = "mock:resultClient4")
> >> >>>>   protected MockEndpoint resultClient4;
> >> >>>>
> >> >>>>   @Test
> >> >>>>   public void testSendBetMessage() throws Exception {
> >> >>>>       log.info("Send a test message to Table Service");
> >> >>>>
> >> >>>>       //resultAllClients.expectedMinimumMessageCount(3);
> >> >>>>       resultClient1.expectedMessageCount(1);
> >> >>>>       resultClient2.expectedMessageCount(1);
> >> >>>>       //resultClient3.expectedMessageCount(1);
> >> >>>>       //resultClient4.expectedMessageCount(1);
> >> >>>>
> >> >>>>
> >> >>>>       // Send the test message to make Server Service create our
> >> Status
> >> >>>> Message
> >> >>>>       producerTemplate.sendBody("jms:queue:bets",
> >> >>>>               ExchangePattern.InOnly, 22);
> >> >>>>
> >> >>>>       // now lets assert that the mock endpoint received messages
> >> >>>>       resultClient1.assertIsSatisfied();
> >> >>>>       resultClient2.assertIsSatisfied();
> >> >>>>       //resultClient3.assertIsSatisfied();
> >> >>>>       //resultClient4.assertIsSatisfied();
> >> >>>>
> >> >>>>       //resultAllClients.assertIsSatisfied();
> >> >>>>       log.info("XXXXXXXXXX DONE
> >> >>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> >> >>>>
> >> >>>>   }
> >> >>>>
> >> >>>>   /*@After
> >> >>>>   public void finalizeTests() {
> >> >>>>       // resultAllClients.reset();
> >> >>>>       resultClient1.reset();
> >> >>>>       resultClient2.reset();
> >> >>>>       resultClient3.reset();
> >> >>>>       // resultClient4.reset();
> >> >>>>   }*/
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>> This is in 1 unit test class and the way it is above has all
> >> assertions
> >> >>>> pass.
> >> >>>> If any of the following things change, I get:
> >> >>>>
> >> >>>> java.lang.AssertionError: mock://resultClient1 Received message
> count.
> >> >>>> Expected: <1> but was: <0>
> >> >>>>
> >> >>>>
> >> >>>> 1. If I uncomment the finalizeTests() method, the error starts.
> >> >>>>
> >> >>> Since the mock endpoints are injected into your unit test, if there
> are
> >> >>> more than one unit test method , you need to reset the mock
> endpoints
> >> to
> >> >>> make sure the message count values are right.
> >> >>>
> >> >>>
> >> >>>> 2. If I uncomment resultClient3, resultClient4 it might start
> working,
> >> >>>> then
> >> >>>> randomly it will show up again and I have to comment them out in
> order
> >> >>>> for
> >> >>>> the test to pass again.
> >> >>>>
> >> >>> I don't know how your mock:resultClient3, mock:resultClient4 can
> >> receive
> >> >>> the message from the route file that you showed me.
> >> >>>
> >> >>>
> >> >>>
> >> >>>> Is there some bug/defect in the Mock that I have not googled?
> >> >>>>
> >> >>>>
> >> >>>>
> >> >>>> ---
> >> >>>> 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
> >> >>>> ---
> >> >>>>
> >> >>>>
> >> >>> Willem
> >> >>>
> >> >>
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> Apache Camel Committer
> >>
> >> Open Source Integration: http://fusesource.com
> >> Blog: http://davsclaus.blogspot.com/
> >> Twitter: http://twitter.com/davsclaus
> >>
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Thanks for understanding.

And I may have been a bit harsh but its just to easy to write and
press the send button :)
Lets start over when we got a better understanding what you want to do
so we can give better advice.

And btw I am not a moderator or hold any special privileges or
anything at this mailinglist.
What I did write was my personal observations.


On Mon, Aug 24, 2009 at 3:04 PM, Mick Knutson<mk...@baselogic.com> wrote:
> 1. I am going to create a blog as I promised, and I am going to start
> writing it this minute to help describe the entire picture and all the piece
> involved. Sorry I have not done this before.
>
> 2. I feel incredibly _bad_ that I have ever come across as yelling
> _ever_.... I would have never consciously done so, and am extremely grateful
> for your help. Again, very, very sorry...
>
>
>
> ---
> 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 24, 2009 at 3:20 AM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> Hi
>>
>> Maybe you should start over and explain to us what you want to test?
>>
>> Its not easy / motivating to help when people shout and post all kind
>> of code and expecting the community to use time / take time to dig
>> into a haystack.
>> Sorry I could not resist stating this.
>>
>> So I suggest to start easy and create a small unit test and maybe
>> instead of JMS try out with pure seda to get the hang of the mock
>> endpoints and how to use them. Then later write unit tests based on
>> JMS.
>>
>>
>>
>>
>> On Mon, Aug 24, 2009 at 8:55 AM, Willem Jiang<wi...@gmail.com>
>> wrote:
>> > Hi
>> >
>> > I still don't know how do you send the message to "seda:resultClient1",
>> > "seda:resultClient2" etc.
>> > BTW
>> >
>> > "seda:resultClient1" is not the same endpoint of "mock:resultClient1"
>> >
>> > Willem
>> > Mick Knutson wrote:
>> >>
>> >> There is only 1 test right now, but I added:
>> >>
>> >>    @Before
>> >>    public void testBefore() throws Exception {
>> >>        log.info("*** Before ***");
>> >>        //assertNotNull(context);
>> >>
>> >>        resultClient1.reset();
>> >>        resultClient2.reset();
>> >>        resultClient3.reset();
>> >>        resultClient4.reset();
>> >>        //resultAllClients.reset();
>> >>    }
>> >>
>> >> already. But I sent another mail a second ago about the tracer.
>> >>
>> >> The strange issue is not getting too many message, but the FIRST mock
>> just
>> >> not getting any messages.
>> >>
>> >> I have even played with commenting out client 1, then I get client 2
>> stops
>> >> getting message randomly. I say randomly, because I have had the test
>> >> working, then I change nothing. But I try to run through 10+ iterations
>> >> through the same test. It will work for several, then just stop. Then it
>> >> might start again. if I keep going, but most of the time not.
>> >>
>> >> I am looking for a pattern to deduce the issue, but it is alluding me.
>> >>
>> >>
>> >>
>> >> ---
>> >> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang
>> >> <wi...@gmail.com>wrote:
>> >>
>> >>> Mick Knutson wrote:
>> >>>
>> >>>> I have a unit test that has a wiretap that routes the message to a
>> mock
>> >>>> endpoint.
>> >>>> Here is what works:
>> >>>>
>> >>>>   @EndpointInject(uri = "mock:resultAllClients")
>> >>>>   protected MockEndpoint resultAllClients;
>> >>>>
>> >>>>   @EndpointInject(uri = "mock:resultClient1")
>> >>>>   protected MockEndpoint resultClient1;
>> >>>>   @EndpointInject(uri = "mock:resultClient2")
>> >>>>   protected MockEndpoint resultClient2;
>> >>>>   @EndpointInject(uri = "mock:resultClient3")
>> >>>>   protected MockEndpoint resultClient3;
>> >>>>   @EndpointInject(uri = "mock:resultClient4")
>> >>>>   protected MockEndpoint resultClient4;
>> >>>>
>> >>>>   @Test
>> >>>>   public void testSendBetMessage() throws Exception {
>> >>>>       log.info("Send a test message to Table Service");
>> >>>>
>> >>>>       //resultAllClients.expectedMinimumMessageCount(3);
>> >>>>       resultClient1.expectedMessageCount(1);
>> >>>>       resultClient2.expectedMessageCount(1);
>> >>>>       //resultClient3.expectedMessageCount(1);
>> >>>>       //resultClient4.expectedMessageCount(1);
>> >>>>
>> >>>>
>> >>>>       // Send the test message to make Server Service create our
>> Status
>> >>>> Message
>> >>>>       producerTemplate.sendBody("jms:queue:bets",
>> >>>>               ExchangePattern.InOnly, 22);
>> >>>>
>> >>>>       // now lets assert that the mock endpoint received messages
>> >>>>       resultClient1.assertIsSatisfied();
>> >>>>       resultClient2.assertIsSatisfied();
>> >>>>       //resultClient3.assertIsSatisfied();
>> >>>>       //resultClient4.assertIsSatisfied();
>> >>>>
>> >>>>       //resultAllClients.assertIsSatisfied();
>> >>>>       log.info("XXXXXXXXXX DONE
>> >>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>> >>>>
>> >>>>   }
>> >>>>
>> >>>>   /*@After
>> >>>>   public void finalizeTests() {
>> >>>>       // resultAllClients.reset();
>> >>>>       resultClient1.reset();
>> >>>>       resultClient2.reset();
>> >>>>       resultClient3.reset();
>> >>>>       // resultClient4.reset();
>> >>>>   }*/
>> >>>>
>> >>>>
>> >>>>
>> >>>> This is in 1 unit test class and the way it is above has all
>> assertions
>> >>>> pass.
>> >>>> If any of the following things change, I get:
>> >>>>
>> >>>> java.lang.AssertionError: mock://resultClient1 Received message count.
>> >>>> Expected: <1> but was: <0>
>> >>>>
>> >>>>
>> >>>> 1. If I uncomment the finalizeTests() method, the error starts.
>> >>>>
>> >>> Since the mock endpoints are injected into your unit test, if there are
>> >>> more than one unit test method , you need to reset the mock endpoints
>> to
>> >>> make sure the message count values are right.
>> >>>
>> >>>
>> >>>> 2. If I uncomment resultClient3, resultClient4 it might start working,
>> >>>> then
>> >>>> randomly it will show up again and I have to comment them out in order
>> >>>> for
>> >>>> the test to pass again.
>> >>>>
>> >>> I don't know how your mock:resultClient3, mock:resultClient4 can
>> receive
>> >>> the message from the route file that you showed me.
>> >>>
>> >>>
>> >>>
>> >>>> Is there some bug/defect in the Mock that I have not googled?
>> >>>>
>> >>>>
>> >>>>
>> >>>> ---
>> >>>> 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
>> >>>> ---
>> >>>>
>> >>>>
>> >>> Willem
>> >>>
>> >>
>> >
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
1. I am going to create a blog as I promised, and I am going to start
writing it this minute to help describe the entire picture and all the piece
involved. Sorry I have not done this before.

2. I feel incredibly _bad_ that I have ever come across as yelling
_ever_.... I would have never consciously done so, and am extremely grateful
for your help. Again, very, very sorry...



---
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 24, 2009 at 3:20 AM, Claus Ibsen <cl...@gmail.com> wrote:

> Hi
>
> Maybe you should start over and explain to us what you want to test?
>
> Its not easy / motivating to help when people shout and post all kind
> of code and expecting the community to use time / take time to dig
> into a haystack.
> Sorry I could not resist stating this.
>
> So I suggest to start easy and create a small unit test and maybe
> instead of JMS try out with pure seda to get the hang of the mock
> endpoints and how to use them. Then later write unit tests based on
> JMS.
>
>
>
>
> On Mon, Aug 24, 2009 at 8:55 AM, Willem Jiang<wi...@gmail.com>
> wrote:
> > Hi
> >
> > I still don't know how do you send the message to "seda:resultClient1",
> > "seda:resultClient2" etc.
> > BTW
> >
> > "seda:resultClient1" is not the same endpoint of "mock:resultClient1"
> >
> > Willem
> > Mick Knutson wrote:
> >>
> >> There is only 1 test right now, but I added:
> >>
> >>    @Before
> >>    public void testBefore() throws Exception {
> >>        log.info("*** Before ***");
> >>        //assertNotNull(context);
> >>
> >>        resultClient1.reset();
> >>        resultClient2.reset();
> >>        resultClient3.reset();
> >>        resultClient4.reset();
> >>        //resultAllClients.reset();
> >>    }
> >>
> >> already. But I sent another mail a second ago about the tracer.
> >>
> >> The strange issue is not getting too many message, but the FIRST mock
> just
> >> not getting any messages.
> >>
> >> I have even played with commenting out client 1, then I get client 2
> stops
> >> getting message randomly. I say randomly, because I have had the test
> >> working, then I change nothing. But I try to run through 10+ iterations
> >> through the same test. It will work for several, then just stop. Then it
> >> might start again. if I keep going, but most of the time not.
> >>
> >> I am looking for a pattern to deduce the issue, but it is alluding me.
> >>
> >>
> >>
> >> ---
> >> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang
> >> <wi...@gmail.com>wrote:
> >>
> >>> Mick Knutson wrote:
> >>>
> >>>> I have a unit test that has a wiretap that routes the message to a
> mock
> >>>> endpoint.
> >>>> Here is what works:
> >>>>
> >>>>   @EndpointInject(uri = "mock:resultAllClients")
> >>>>   protected MockEndpoint resultAllClients;
> >>>>
> >>>>   @EndpointInject(uri = "mock:resultClient1")
> >>>>   protected MockEndpoint resultClient1;
> >>>>   @EndpointInject(uri = "mock:resultClient2")
> >>>>   protected MockEndpoint resultClient2;
> >>>>   @EndpointInject(uri = "mock:resultClient3")
> >>>>   protected MockEndpoint resultClient3;
> >>>>   @EndpointInject(uri = "mock:resultClient4")
> >>>>   protected MockEndpoint resultClient4;
> >>>>
> >>>>   @Test
> >>>>   public void testSendBetMessage() throws Exception {
> >>>>       log.info("Send a test message to Table Service");
> >>>>
> >>>>       //resultAllClients.expectedMinimumMessageCount(3);
> >>>>       resultClient1.expectedMessageCount(1);
> >>>>       resultClient2.expectedMessageCount(1);
> >>>>       //resultClient3.expectedMessageCount(1);
> >>>>       //resultClient4.expectedMessageCount(1);
> >>>>
> >>>>
> >>>>       // Send the test message to make Server Service create our
> Status
> >>>> Message
> >>>>       producerTemplate.sendBody("jms:queue:bets",
> >>>>               ExchangePattern.InOnly, 22);
> >>>>
> >>>>       // now lets assert that the mock endpoint received messages
> >>>>       resultClient1.assertIsSatisfied();
> >>>>       resultClient2.assertIsSatisfied();
> >>>>       //resultClient3.assertIsSatisfied();
> >>>>       //resultClient4.assertIsSatisfied();
> >>>>
> >>>>       //resultAllClients.assertIsSatisfied();
> >>>>       log.info("XXXXXXXXXX DONE
> >>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> >>>>
> >>>>   }
> >>>>
> >>>>   /*@After
> >>>>   public void finalizeTests() {
> >>>>       // resultAllClients.reset();
> >>>>       resultClient1.reset();
> >>>>       resultClient2.reset();
> >>>>       resultClient3.reset();
> >>>>       // resultClient4.reset();
> >>>>   }*/
> >>>>
> >>>>
> >>>>
> >>>> This is in 1 unit test class and the way it is above has all
> assertions
> >>>> pass.
> >>>> If any of the following things change, I get:
> >>>>
> >>>> java.lang.AssertionError: mock://resultClient1 Received message count.
> >>>> Expected: <1> but was: <0>
> >>>>
> >>>>
> >>>> 1. If I uncomment the finalizeTests() method, the error starts.
> >>>>
> >>> Since the mock endpoints are injected into your unit test, if there are
> >>> more than one unit test method , you need to reset the mock endpoints
> to
> >>> make sure the message count values are right.
> >>>
> >>>
> >>>> 2. If I uncomment resultClient3, resultClient4 it might start working,
> >>>> then
> >>>> randomly it will show up again and I have to comment them out in order
> >>>> for
> >>>> the test to pass again.
> >>>>
> >>> I don't know how your mock:resultClient3, mock:resultClient4 can
> receive
> >>> the message from the route file that you showed me.
> >>>
> >>>
> >>>
> >>>> Is there some bug/defect in the Mock that I have not googled?
> >>>>
> >>>>
> >>>>
> >>>> ---
> >>>> 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
> >>>> ---
> >>>>
> >>>>
> >>> Willem
> >>>
> >>
> >
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Maybe you should start over and explain to us what you want to test?

Its not easy / motivating to help when people shout and post all kind
of code and expecting the community to use time / take time to dig
into a haystack.
Sorry I could not resist stating this.

So I suggest to start easy and create a small unit test and maybe
instead of JMS try out with pure seda to get the hang of the mock
endpoints and how to use them. Then later write unit tests based on
JMS.




On Mon, Aug 24, 2009 at 8:55 AM, Willem Jiang<wi...@gmail.com> wrote:
> Hi
>
> I still don't know how do you send the message to "seda:resultClient1",
> "seda:resultClient2" etc.
> BTW
>
> "seda:resultClient1" is not the same endpoint of "mock:resultClient1"
>
> Willem
> Mick Knutson wrote:
>>
>> There is only 1 test right now, but I added:
>>
>>    @Before
>>    public void testBefore() throws Exception {
>>        log.info("*** Before ***");
>>        //assertNotNull(context);
>>
>>        resultClient1.reset();
>>        resultClient2.reset();
>>        resultClient3.reset();
>>        resultClient4.reset();
>>        //resultAllClients.reset();
>>    }
>>
>> already. But I sent another mail a second ago about the tracer.
>>
>> The strange issue is not getting too many message, but the FIRST mock just
>> not getting any messages.
>>
>> I have even played with commenting out client 1, then I get client 2 stops
>> getting message randomly. I say randomly, because I have had the test
>> working, then I change nothing. But I try to run through 10+ iterations
>> through the same test. It will work for several, then just stop. Then it
>> might start again. if I keep going, but most of the time not.
>>
>> I am looking for a pattern to deduce the issue, but it is alluding me.
>>
>>
>>
>> ---
>> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang
>> <wi...@gmail.com>wrote:
>>
>>> Mick Knutson wrote:
>>>
>>>> I have a unit test that has a wiretap that routes the message to a mock
>>>> endpoint.
>>>> Here is what works:
>>>>
>>>>   @EndpointInject(uri = "mock:resultAllClients")
>>>>   protected MockEndpoint resultAllClients;
>>>>
>>>>   @EndpointInject(uri = "mock:resultClient1")
>>>>   protected MockEndpoint resultClient1;
>>>>   @EndpointInject(uri = "mock:resultClient2")
>>>>   protected MockEndpoint resultClient2;
>>>>   @EndpointInject(uri = "mock:resultClient3")
>>>>   protected MockEndpoint resultClient3;
>>>>   @EndpointInject(uri = "mock:resultClient4")
>>>>   protected MockEndpoint resultClient4;
>>>>
>>>>   @Test
>>>>   public void testSendBetMessage() throws Exception {
>>>>       log.info("Send a test message to Table Service");
>>>>
>>>>       //resultAllClients.expectedMinimumMessageCount(3);
>>>>       resultClient1.expectedMessageCount(1);
>>>>       resultClient2.expectedMessageCount(1);
>>>>       //resultClient3.expectedMessageCount(1);
>>>>       //resultClient4.expectedMessageCount(1);
>>>>
>>>>
>>>>       // Send the test message to make Server Service create our Status
>>>> Message
>>>>       producerTemplate.sendBody("jms:queue:bets",
>>>>               ExchangePattern.InOnly, 22);
>>>>
>>>>       // now lets assert that the mock endpoint received messages
>>>>       resultClient1.assertIsSatisfied();
>>>>       resultClient2.assertIsSatisfied();
>>>>       //resultClient3.assertIsSatisfied();
>>>>       //resultClient4.assertIsSatisfied();
>>>>
>>>>       //resultAllClients.assertIsSatisfied();
>>>>       log.info("XXXXXXXXXX DONE
>>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>>>
>>>>   }
>>>>
>>>>   /*@After
>>>>   public void finalizeTests() {
>>>>       // resultAllClients.reset();
>>>>       resultClient1.reset();
>>>>       resultClient2.reset();
>>>>       resultClient3.reset();
>>>>       // resultClient4.reset();
>>>>   }*/
>>>>
>>>>
>>>>
>>>> This is in 1 unit test class and the way it is above has all assertions
>>>> pass.
>>>> If any of the following things change, I get:
>>>>
>>>> java.lang.AssertionError: mock://resultClient1 Received message count.
>>>> Expected: <1> but was: <0>
>>>>
>>>>
>>>> 1. If I uncomment the finalizeTests() method, the error starts.
>>>>
>>> Since the mock endpoints are injected into your unit test, if there are
>>> more than one unit test method , you need to reset the mock endpoints to
>>> make sure the message count values are right.
>>>
>>>
>>>> 2. If I uncomment resultClient3, resultClient4 it might start working,
>>>> then
>>>> randomly it will show up again and I have to comment them out in order
>>>> for
>>>> the test to pass again.
>>>>
>>> I don't know how your mock:resultClient3, mock:resultClient4 can receive
>>> the message from the route file that you showed me.
>>>
>>>
>>>
>>>> Is there some bug/defect in the Mock that I have not googled?
>>>>
>>>>
>>>>
>>>> ---
>>>> 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
>>>> ---
>>>>
>>>>
>>> Willem
>>>
>>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: frustration with multiple mock endpoints in 1 unit test.

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

I still don't know how do you send the message to "seda:resultClient1", 
"seda:resultClient2" etc.
BTW

"seda:resultClient1" is not the same endpoint of "mock:resultClient1"

Willem
Mick Knutson wrote:
> There is only 1 test right now, but I added:
> 
>     @Before
>     public void testBefore() throws Exception {
>         log.info("*** Before ***");
>         //assertNotNull(context);
> 
>         resultClient1.reset();
>         resultClient2.reset();
>         resultClient3.reset();
>         resultClient4.reset();
>         //resultAllClients.reset();
>     }
> 
> already. But I sent another mail a second ago about the tracer.
> 
> The strange issue is not getting too many message, but the FIRST mock just
> not getting any messages.
> 
> I have even played with commenting out client 1, then I get client 2 stops
> getting message randomly. I say randomly, because I have had the test
> working, then I change nothing. But I try to run through 10+ iterations
> through the same test. It will work for several, then just stop. Then it
> might start again. if I keep going, but most of the time not.
> 
> I am looking for a pattern to deduce the issue, but it is alluding me.
> 
> 
> 
> ---
> 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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang <wi...@gmail.com>wrote:
> 
>> Mick Knutson wrote:
>>
>>> I have a unit test that has a wiretap that routes the message to a mock
>>> endpoint.
>>> Here is what works:
>>>
>>>    @EndpointInject(uri = "mock:resultAllClients")
>>>    protected MockEndpoint resultAllClients;
>>>
>>>    @EndpointInject(uri = "mock:resultClient1")
>>>    protected MockEndpoint resultClient1;
>>>    @EndpointInject(uri = "mock:resultClient2")
>>>    protected MockEndpoint resultClient2;
>>>    @EndpointInject(uri = "mock:resultClient3")
>>>    protected MockEndpoint resultClient3;
>>>    @EndpointInject(uri = "mock:resultClient4")
>>>    protected MockEndpoint resultClient4;
>>>
>>>    @Test
>>>    public void testSendBetMessage() throws Exception {
>>>        log.info("Send a test message to Table Service");
>>>
>>>        //resultAllClients.expectedMinimumMessageCount(3);
>>>        resultClient1.expectedMessageCount(1);
>>>        resultClient2.expectedMessageCount(1);
>>>        //resultClient3.expectedMessageCount(1);
>>>        //resultClient4.expectedMessageCount(1);
>>>
>>>
>>>        // Send the test message to make Server Service create our Status
>>> Message
>>>        producerTemplate.sendBody("jms:queue:bets",
>>>                ExchangePattern.InOnly, 22);
>>>
>>>        // now lets assert that the mock endpoint received messages
>>>        resultClient1.assertIsSatisfied();
>>>        resultClient2.assertIsSatisfied();
>>>        //resultClient3.assertIsSatisfied();
>>>        //resultClient4.assertIsSatisfied();
>>>
>>>        //resultAllClients.assertIsSatisfied();
>>>        log.info("XXXXXXXXXX DONE
>>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>>
>>>    }
>>>
>>>    /*@After
>>>    public void finalizeTests() {
>>>        // resultAllClients.reset();
>>>        resultClient1.reset();
>>>        resultClient2.reset();
>>>        resultClient3.reset();
>>>        // resultClient4.reset();
>>>    }*/
>>>
>>>
>>>
>>> This is in 1 unit test class and the way it is above has all assertions
>>> pass.
>>> If any of the following things change, I get:
>>>
>>> java.lang.AssertionError: mock://resultClient1 Received message count.
>>> Expected: <1> but was: <0>
>>>
>>>
>>> 1. If I uncomment the finalizeTests() method, the error starts.
>>>
>> Since the mock endpoints are injected into your unit test, if there are
>> more than one unit test method , you need to reset the mock endpoints to
>> make sure the message count values are right.
>>
>>
>>> 2. If I uncomment resultClient3, resultClient4 it might start working,
>>> then
>>> randomly it will show up again and I have to comment them out in order for
>>> the test to pass again.
>>>
>> I don't know how your mock:resultClient3, mock:resultClient4 can receive
>> the message from the route file that you showed me.
>>
>>
>>
>>> Is there some bug/defect in the Mock that I have not googled?
>>>
>>>
>>>
>>> ---
>>> 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
>>> ---
>>>
>>>
>> Willem
>>
> 


Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Mick Knutson <mk...@baselogic.com>.
There is only 1 test right now, but I added:

    @Before
    public void testBefore() throws Exception {
        log.info("*** Before ***");
        //assertNotNull(context);

        resultClient1.reset();
        resultClient2.reset();
        resultClient3.reset();
        resultClient4.reset();
        //resultAllClients.reset();
    }

already. But I sent another mail a second ago about the tracer.

The strange issue is not getting too many message, but the FIRST mock just
not getting any messages.

I have even played with commenting out client 1, then I get client 2 stops
getting message randomly. I say randomly, because I have had the test
working, then I change nothing. But I try to run through 10+ iterations
through the same test. It will work for several, then just stop. Then it
might start again. if I keep going, but most of the time not.

I am looking for a pattern to deduce the issue, but it is alluding me.



---
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 Sun, Aug 23, 2009 at 6:14 AM, Willem Jiang <wi...@gmail.com>wrote:

> Mick Knutson wrote:
>
>> I have a unit test that has a wiretap that routes the message to a mock
>> endpoint.
>> Here is what works:
>>
>>    @EndpointInject(uri = "mock:resultAllClients")
>>    protected MockEndpoint resultAllClients;
>>
>>    @EndpointInject(uri = "mock:resultClient1")
>>    protected MockEndpoint resultClient1;
>>    @EndpointInject(uri = "mock:resultClient2")
>>    protected MockEndpoint resultClient2;
>>    @EndpointInject(uri = "mock:resultClient3")
>>    protected MockEndpoint resultClient3;
>>    @EndpointInject(uri = "mock:resultClient4")
>>    protected MockEndpoint resultClient4;
>>
>>    @Test
>>    public void testSendBetMessage() throws Exception {
>>        log.info("Send a test message to Table Service");
>>
>>        //resultAllClients.expectedMinimumMessageCount(3);
>>        resultClient1.expectedMessageCount(1);
>>        resultClient2.expectedMessageCount(1);
>>        //resultClient3.expectedMessageCount(1);
>>        //resultClient4.expectedMessageCount(1);
>>
>>
>>        // Send the test message to make Server Service create our Status
>> Message
>>        producerTemplate.sendBody("jms:queue:bets",
>>                ExchangePattern.InOnly, 22);
>>
>>        // now lets assert that the mock endpoint received messages
>>        resultClient1.assertIsSatisfied();
>>        resultClient2.assertIsSatisfied();
>>        //resultClient3.assertIsSatisfied();
>>        //resultClient4.assertIsSatisfied();
>>
>>        //resultAllClients.assertIsSatisfied();
>>        log.info("XXXXXXXXXX DONE
>> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
>>
>>    }
>>
>>    /*@After
>>    public void finalizeTests() {
>>        // resultAllClients.reset();
>>        resultClient1.reset();
>>        resultClient2.reset();
>>        resultClient3.reset();
>>        // resultClient4.reset();
>>    }*/
>>
>>
>>
>> This is in 1 unit test class and the way it is above has all assertions
>> pass.
>> If any of the following things change, I get:
>>
>> java.lang.AssertionError: mock://resultClient1 Received message count.
>> Expected: <1> but was: <0>
>>
>>
>> 1. If I uncomment the finalizeTests() method, the error starts.
>>
> Since the mock endpoints are injected into your unit test, if there are
> more than one unit test method , you need to reset the mock endpoints to
> make sure the message count values are right.
>
>
>> 2. If I uncomment resultClient3, resultClient4 it might start working,
>> then
>> randomly it will show up again and I have to comment them out in order for
>> the test to pass again.
>>
>
> I don't know how your mock:resultClient3, mock:resultClient4 can receive
> the message from the route file that you showed me.
>
>
>
>>
>> Is there some bug/defect in the Mock that I have not googled?
>>
>>
>>
>> ---
>> 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
>> ---
>>
>>
> Willem
>

Re: frustration with multiple mock endpoints in 1 unit test.

Posted by Willem Jiang <wi...@gmail.com>.
Mick Knutson wrote:
> I have a unit test that has a wiretap that routes the message to a mock
> endpoint.
> Here is what works:
> 
>     @EndpointInject(uri = "mock:resultAllClients")
>     protected MockEndpoint resultAllClients;
> 
>     @EndpointInject(uri = "mock:resultClient1")
>     protected MockEndpoint resultClient1;
>     @EndpointInject(uri = "mock:resultClient2")
>     protected MockEndpoint resultClient2;
>     @EndpointInject(uri = "mock:resultClient3")
>     protected MockEndpoint resultClient3;
>     @EndpointInject(uri = "mock:resultClient4")
>     protected MockEndpoint resultClient4;
> 
>     @Test
>     public void testSendBetMessage() throws Exception {
>         log.info("Send a test message to Table Service");
> 
>         //resultAllClients.expectedMinimumMessageCount(3);
>         resultClient1.expectedMessageCount(1);
>         resultClient2.expectedMessageCount(1);
>         //resultClient3.expectedMessageCount(1);
>         //resultClient4.expectedMessageCount(1);
> 
> 
>         // Send the test message to make Server Service create our Status
> Message
>         producerTemplate.sendBody("jms:queue:bets",
>                 ExchangePattern.InOnly, 22);
> 
>         // now lets assert that the mock endpoint received messages
>         resultClient1.assertIsSatisfied();
>         resultClient2.assertIsSatisfied();
>         //resultClient3.assertIsSatisfied();
>         //resultClient4.assertIsSatisfied();
> 
>         //resultAllClients.assertIsSatisfied();
>         log.info("XXXXXXXXXX DONE
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
> 
>     }
> 
>     /*@After
>     public void finalizeTests() {
>         // resultAllClients.reset();
>         resultClient1.reset();
>         resultClient2.reset();
>         resultClient3.reset();
>         // resultClient4.reset();
>     }*/
> 
> 
> 
> This is in 1 unit test class and the way it is above has all assertions
> pass.
> If any of the following things change, I get:
> 
> java.lang.AssertionError: mock://resultClient1 Received message count.
> Expected: <1> but was: <0>
> 
> 
> 1. If I uncomment the finalizeTests() method, the error starts.
Since the mock endpoints are injected into your unit test, if there are 
more than one unit test method , you need to reset the mock endpoints to 
make sure the message count values are right.

> 
> 2. If I uncomment resultClient3, resultClient4 it might start working, then
> randomly it will show up again and I have to comment them out in order for
> the test to pass again.

I don't know how your mock:resultClient3, mock:resultClient4 can receive 
the message from the route file that you showed me.

> 
> 
> Is there some bug/defect in the Mock that I have not googled?
> 
> 
> 
> ---
> 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
> ---
> 

Willem