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

fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 93c758ff7be Fix and improve kafka tests
93c758ff7be is described below

commit 93c758ff7be374dcaab95f8610999365030efb74
Author: Croway <[email protected]>
AuthorDate: Fri Feb 27 16:45:00 2026 +0100

    Fix and improve kafka tests
---
 components-starter/camel-kafka-starter/pom.xml     | 31 +--------------
 .../integration/BaseEmbeddedKafkaTestSupport.java  |  2 +-
 .../KafkaConsumerAsyncManualCommitIT.java          |  2 +-
 .../KafkaConsumerLastRecordHeaderIT.java           |  2 +-
 .../integration/KafkaConsumerManualCommitIT.java   |  4 +-
 .../integration/KafkaConsumerTopicIsPatternIT.java |  6 +--
 .../component/kafka/integration/KafkaToDIT.java    |  2 +-
 .../src/test/resources/logback.xml                 | 46 ++++++++++++++++++++++
 8 files changed, 56 insertions(+), 39 deletions(-)

diff --git a/components-starter/camel-kafka-starter/pom.xml 
b/components-starter/camel-kafka-starter/pom.xml
index a453691727f..07a6cfb1ace 100644
--- a/components-starter/camel-kafka-starter/pom.xml
+++ b/components-starter/camel-kafka-starter/pom.xml
@@ -96,6 +96,7 @@
             <redirectTestOutputToFile>false</redirectTestOutputToFile>
             <systemPropertyVariables>
               <visibleassertions.silence>true</visibleassertions.silence>
+              <kafka.instance.type>local-kafka-container</kafka.instance.type>
             </systemPropertyVariables>
           </configuration>
         </plugin>
@@ -118,21 +119,6 @@
             <artifactId>maven-failsafe-plugin</artifactId>
             <executions>
               <execution>
-                <id>integration-test</id>
-                <phase>verify</phase>
-                <goals>
-                  <goal>integration-test</goal>
-                  <goal>verify</goal>
-                </goals>
-              </execution>
-              <execution>
-                <id>kafka-3</id>
-                <configuration>
-                  <systemPropertyVariables>
-                    
<kafka.instance.type>local-kafka3-container</kafka.instance.type>
-                  </systemPropertyVariables>
-                  <reportNameSuffix>kafka-3</reportNameSuffix>
-                </configuration>
                 <goals>
                   <goal>integration-test</goal>
                   <goal>verify</goal>
@@ -158,21 +144,6 @@
             <artifactId>maven-failsafe-plugin</artifactId>
             <executions>
               <execution>
-                <id>integration-test</id>
-                <phase>verify</phase>
-                <goals>
-                  <goal>integration-test</goal>
-                  <goal>verify</goal>
-                </goals>
-              </execution>
-              <execution>
-                <id>kafka-3</id>
-                <configuration>
-                  <systemPropertyVariables>
-                    
<kafka.instance.type>local-kafka3-container</kafka.instance.type>
-                  </systemPropertyVariables>
-                  <reportNameSuffix>kafka-3</reportNameSuffix>
-                </configuration>
                 <goals>
                   <goal>integration-test</goal>
                   <goal>verify</goal>
diff --git 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/BaseEmbeddedKafkaTestSupport.java
 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/BaseEmbeddedKafkaTestSupport.java
index 5c056fb1586..49d0a2f8b37 100644
--- 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/BaseEmbeddedKafkaTestSupport.java
+++ 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/BaseEmbeddedKafkaTestSupport.java
@@ -38,7 +38,7 @@ import org.springframework.context.annotation.Configuration;
 public abstract class BaseEmbeddedKafkaTestSupport {
 
     @RegisterExtension
-    public static KafkaService service = KafkaServiceFactory.createService();
+    public static KafkaService service = 
KafkaServiceFactory.createSingletonService();
 
     @Autowired
     protected CamelContext context;
diff --git 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java
 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java
index 5960a00c516..cbfa8b3660f 100644
--- 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java
+++ 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerAsyncManualCommitIT.java
@@ -78,7 +78,7 @@ public class KafkaConsumerAsyncManualCommitIT extends 
BaseEmbeddedKafkaTestSuppo
         kafkaAdminClient.deleteTopics(Collections.singletonList(TOPIC));
     }
 
-    @RepeatedTest(4)
+    @RepeatedTest(2)
     public void kafkaManualCommit() throws Exception {
         to.expectedMessageCount(5);
         to.expectedBodiesReceivedInAnyOrder("message-0", "message-1", 
"message-2", "message-3", "message-4");
diff --git 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerLastRecordHeaderIT.java
 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerLastRecordHeaderIT.java
index 7b2d1f168a8..e1f195f3243 100644
--- 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerLastRecordHeaderIT.java
+++ 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerLastRecordHeaderIT.java
@@ -39,7 +39,7 @@ import org.springframework.test.annotation.DirtiesContext;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
 @CamelSpringBootTest
 @SpringBootTest(classes = { CamelAutoConfiguration.class, 
BaseEmbeddedKafkaTestSupport.DefaulKafkaComponent.class,
         KafkaConsumerLastRecordHeaderIT.class, 
KafkaConsumerLastRecordHeaderIT.TestConfiguration.class, })
diff --git 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerManualCommitIT.java
 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerManualCommitIT.java
index 7da6bf4b31c..11b63ed4b3a 100644
--- 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerManualCommitIT.java
+++ 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerManualCommitIT.java
@@ -72,7 +72,7 @@ public class KafkaConsumerManualCommitIT extends 
BaseEmbeddedKafkaTestSupport {
         kafkaAdminClient.deleteTopics(Collections.singletonList(TOPIC));
     }
 
-    @RepeatedTest(4)
+    @RepeatedTest(2)
     public void kafkaAutoCommitDisabledDuringRebalance() throws Exception {
         to.expectedMessageCount(1);
         String firstMessage = "message-0";
@@ -112,7 +112,7 @@ public class KafkaConsumerManualCommitIT extends 
BaseEmbeddedKafkaTestSupport {
         to.assertIsSatisfied(3000);
     }
 
-    @RepeatedTest(4)
+    @RepeatedTest(2)
     public void kafkaManualCommit() throws Exception {
         to.expectedMessageCount(5);
         to.expectedBodiesReceivedInAnyOrder("message-0", "message-1", 
"message-2", "message-3", "message-4");
diff --git 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
index 96a5c96a866..fba328fd6db 100644
--- 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
+++ 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerTopicIsPatternIT.java
@@ -37,7 +37,7 @@ import org.springframework.test.annotation.DirtiesContext;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
 @CamelSpringBootTest
 @SpringBootTest(classes = { CamelAutoConfiguration.class, 
BaseEmbeddedKafkaTestSupport.DefaulKafkaComponent.class,
         KafkaConsumerTopicIsPatternIT.class, 
KafkaConsumerTopicIsPatternIT.TestConfiguration.class, })
@@ -48,8 +48,8 @@ public class KafkaConsumerTopicIsPatternIT extends 
BaseEmbeddedKafkaTestSupport
     public static final String TOPIC_PATTERN = "v.*d";
 
     private final String from = "kafka:" + TOPIC_PATTERN
-            + "?topicIsPattern=true&groupId=group1&autoOffsetReset=earliest"
-            + 
"&autoCommitIntervalMs=1000&sessionTimeoutMs=30000&autoCommitEnable=true&interceptorClasses=org.apache.camel.component.kafka.integration.MockConsumerInterceptor";
+            + 
"?topicIsPattern=true&groupId=KafkaConsumerTopicIsPatternIT&autoOffsetReset=earliest"
+            + 
"&autoCommitIntervalMs=1000&sessionTimeoutMs=30000&autoCommitEnable=true&pollTimeoutMs=1000&metadataMaxAgeMs=1000&interceptorClasses=org.apache.camel.component.kafka.integration.MockConsumerInterceptor";
 
     @EndpointInject("mock:result")
     private MockEndpoint to;
diff --git 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java
 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java
index a3597f494fc..de213e41cce 100644
--- 
a/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java
+++ 
b/components-starter/camel-kafka-starter/src/test/java/org/apache/camel/component/kafka/integration/KafkaToDIT.java
@@ -30,7 +30,7 @@ import org.springframework.test.annotation.DirtiesContext;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
 @CamelSpringBootTest
 @SpringBootTest(classes = { CamelAutoConfiguration.class, 
BaseEmbeddedKafkaTestSupport.DefaulKafkaComponent.class,
         KafkaToDIT.class, KafkaToDIT.TestConfiguration.class, })
diff --git 
a/components-starter/camel-kafka-starter/src/test/resources/logback.xml 
b/components-starter/camel-kafka-starter/src/test/resources/logback.xml
new file mode 100644
index 00000000000..f698353edda
--- /dev/null
+++ b/components-starter/camel-kafka-starter/src/test/resources/logback.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<configuration>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - 
%msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+    <encoder>
+      <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - 
%msg%n</pattern>
+    </encoder>
+    <file>target/camel-kafka-starter-test.log</file>
+  </appender>
+
+  <!-- Silence noisy Kafka client internals -->
+  <logger name="org.apache.kafka" level="WARN"/>
+
+  <!-- Keep testcontainers at INFO for container lifecycle visibility -->
+  <logger name="org.testcontainers" level="INFO"/>
+  <logger name="tc" level="INFO"/>
+
+  <root level="INFO">
+    <appender-ref ref="FILE"/>
+  </root>
+
+</configuration>

Reply via email to