[ 
https://issues.apache.org/jira/browse/CAMEL-12852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16637212#comment-16637212
 ] 

ASF GitHub Bot commented on CAMEL-12852:
----------------------------------------

oscerd closed pull request #2548: CAMEL-12852 - use minimum expected message 
count
URL: https://github.com/apache/camel/pull/2548
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresenceTest.java
 
b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresenceTest.java
index dc83b819102..f89ebec2564 100644
--- 
a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresenceTest.java
+++ 
b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresenceTest.java
@@ -48,7 +48,7 @@ public void testPresence() throws Exception {
                           + 
"{\"a\":\"4\",\"f\":512,\"p\":{\"t\":\"14637536741726901\",\"r\":1},\"k\":\"demo-36\",\"c\":\"mychannel-pnpres\",\"d\":{\"action\":
 \"state-change\", "
                           + "\"timestamp\": 1463753674, \"data\": {\"state\": 
\"cool\"}, \"uuid\": \"24c9bb19-1fcd-4c40-a6f1-522a8a1329ef\", \"occupancy\": 
3},\"b\":\"mychannel-pnpres\"}]}")));
         context.startRoute("presence-route");
-        mockResult.expectedMessageCount(1);
+        mockResult.expectedMinimumMessageCount(1);
         mockResult.expectedHeaderReceived(PubNubConstants.CHANNEL, 
"mychannel");
         assertMockEndpointsSatisfied();
         PNPresenceEventResult presence = 
mockResult.getReceivedExchanges().get(0).getIn().getBody(PNPresenceEventResult.class);
@@ -67,7 +67,7 @@ public void testPresenceWithHereNowRefresh() throws Exception 
{
                           + "\"d\":{\"action\": \"interval\", \"timestamp\": 
1490124758, \"occupancy\": 2, \"here_now_refresh\": true, "
                           + "\"join\": 
[\"2220E216-5A30-49AD-A89C-1E0B5AE26AD7\", 
\"4262AE3F-3202-4487-BEE0-1A0D91307DEB\"]},\"b\":\"mychannel-pnpres\"}]}")));
         context.startRoute("presence-route");
-        mockResult.expectedMessageCount(1);
+        mockResult.expectedMinimumMessageCount(1);
         assertMockEndpointsSatisfied();
         PNPresenceEventResult presence = 
mockResult.getReceivedExchanges().get(0).getIn().getBody(PNPresenceEventResult.class);
         assertThat(presence.getHereNowRefresh(), equalTo(true));


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Fix unstable test PubNubPresenceTest
> ------------------------------------
>
>                 Key: CAMEL-12852
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12852
>             Project: Camel
>          Issue Type: Bug
>          Components: tests
>            Reporter: Aurélien Pupier
>            Assignee: Andrea Cosentino
>            Priority: Minor
>             Fix For: 2.21.3, 2.22.2, 2.23.0
>
>
> sometimes it is failing with
> https://fusesource-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/job/camel.redhat.pipeline/job/2.21.x.redhat-7-0-x/18/testReport/junit/org.apache.camel.component.pubnub/PubNubPresenceTest/testPresence/
> {quote}Error Message
> mock://result Received message count. Expected: <1> but was: <2>
> Stacktrace
> java.lang.AssertionError: mock://result Received message count. Expected: <1> 
> but was: <2>
>       at 
> org.apache.camel.component.pubnub.PubNubPresenceTest.testPresence(PubNubPresenceTest.java:53){quote}
> the problem is that in fact a lot of exchanges are created.
> In org.apache.camel.component.mock.MockEndpoint.doAssertIsSatisfied(long), it 
> is waiting to reach at least the given expected number in the provided 
> timeout.
> As soon as it is reached, it is doing the assertion.
> But between the assertion done in the line just after, a new message may 
> arrive.
> You can notice it by putting a Thread.sleep(1000) for instance before the 
> assertEquals, with PubNubTest it wil lalways fail and there will be a lo 
> tmore messages.
> So 3 possibilities:
> - the test should expect a minimum number of messages
> - the route used in test should be modified to trigger a single message
> - the camel product should not create several messages and in this case it is 
> a product bug



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to