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

orpiske 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 72d202e  camel-kafka: fix flaky kafka test 
KafkaConsumerTopicIsPatternIT
72d202e is described below

commit 72d202e5a38b9ee4a802d257193043b7a1fc477d
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Wed Sep 29 10:34:27 2021 +0200

    camel-kafka: fix flaky kafka test KafkaConsumerTopicIsPatternIT
    
    - prevent the code from reusing the same topic as previous test
    - ensure the mock interceptor is cleared before the test
---
 .../component/kafka/integration/KafkaConsumerTopicIsPatternIT.java | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
 
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
index 50281ed..5c4702a 100644
--- 
a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
+++ 
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
@@ -35,8 +35,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class KafkaConsumerTopicIsPatternIT extends 
BaseEmbeddedKafkaTestSupport {
 
-    public static final String TOPIC = "test";
-    public static final String TOPIC_PATTERN = "t\\w\\wt";
+    public static final String TOPIC = "vess123d";
+    public static final String TOPIC_PATTERN = "v.*d";
 
     @EndpointInject("kafka:" + TOPIC_PATTERN + 
"?topicIsPattern=true&groupId=group1&autoOffsetReset=earliest"
                     + 
"&autoCommitIntervalMs=1000&sessionTimeoutMs=30000&autoCommitEnable=true&interceptorClasses=org.apache.camel.component.kafka.MockConsumerInterceptor")
@@ -51,6 +51,7 @@ public class KafkaConsumerTopicIsPatternIT extends 
BaseEmbeddedKafkaTestSupport
     public void before() {
         Properties props = getDefaultProperties();
         producer = new 
org.apache.kafka.clients.producer.KafkaProducer<>(props);
+        MockConsumerInterceptor.recordsCaptured.clear();
 
     }
 
@@ -78,7 +79,7 @@ public class KafkaConsumerTopicIsPatternIT extends 
BaseEmbeddedKafkaTestSupport
     public void kafkaTopicIsPattern() throws Exception {
         to.expectedMessageCount(5);
         to.expectedBodiesReceivedInAnyOrder("message-0", "message-1", 
"message-2", "message-3", "message-4");
-        to.allMessages().header(KafkaConstants.TOPIC).isEqualTo("test");
+        to.allMessages().header(KafkaConstants.TOPIC).isEqualTo(TOPIC);
         // The LAST_RECORD_BEFORE_COMMIT header should not be configured on any
         // exchange because autoCommitEnable=true
         
to.expectedHeaderValuesReceivedInAnyOrder(KafkaConstants.LAST_RECORD_BEFORE_COMMIT,
 null, null, null, null, null);

Reply via email to