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 <willem.ji...@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 >