This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 86bb75ab15ce CAMEL-26372: camel-mail - Fix flaky 
MailMaxMessagesPerPollTest (#29723)
86bb75ab15ce is described below

commit 86bb75ab15ce3d8ed5fad6f6ab42901555ab2fdc
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Thu Nov 12 21:46:19 2026 +0100

    CAMEL-26372: camel-mail - Fix flaky MailMaxMessagesPerPollTest (#29723)
    
    Two sources of flakiness in MailMaxMessagesPerPollTest.testBatchConsumer:
    
    - mock.setResultWaitTime(2000) gave the first poll only 2 seconds to 
deliver the first batch; the override is removed so the MockEndpoint default 
wait applies.
    - A race between the two batches: if the second poll ran before 
mock.reset(), its exchanges were discarded. The test now expects all 5 messages 
in a single assertion, checking the body and Exchange.BATCH_SIZE (3 for the 
first batch, 2 for the second) of each message, so no reset() is needed.
    
    AI-generated by IBM Bob 2.2.1 on behalf of apupier.
    
    Co-authored-by: IBM Bob 2.2.1
---
 .../component/mail/MailMaxMessagesPerPollTest.java   | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git 
a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java
 
b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java
index c7c0c2edc077..c70ebb38ad1b 100644
--- 
a/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java
+++ 
b/components/camel-mail/src/test/java/org/apache/camel/component/mail/MailMaxMessagesPerPollTest.java
@@ -43,20 +43,18 @@ public class MailMaxMessagesPerPollTest extends 
CamelTestSupport {
     @Test
     public void testBatchConsumer() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.setResultWaitTime(2000);
-        mock.expectedMessageCount(3);
+        // the second poll may happen right after the first one, so verify 
both batches in a single expectation
+        mock.expectedMessageCount(5);
         mock.message(0).body().isEqualTo("Message 0");
         mock.message(1).body().isEqualTo("Message 1");
         mock.message(2).body().isEqualTo("Message 2");
-        mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 3);
-
-        MockEndpoint.assertIsSatisfied(context);
-
-        mock.reset();
-        mock.expectedMessageCount(2);
-        mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
-        mock.message(0).body().isEqualTo("Message 3");
-        mock.message(1).body().isEqualTo("Message 4");
+        mock.message(3).body().isEqualTo("Message 3");
+        mock.message(4).body().isEqualTo("Message 4");
+        mock.message(0).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(3);
+        mock.message(1).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(3);
+        mock.message(2).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(3);
+        mock.message(3).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(2);
+        mock.message(4).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(2);
 
         MockEndpoint.assertIsSatisfied(context);
     }

Reply via email to