chia7712 commented on code in PR #19298:
URL: https://github.com/apache/kafka/pull/19298#discussion_r2043987552


##########
clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/consumer/PlaintextConsumerCallbackTest.java:
##########
@@ -0,0 +1,370 @@
+/*
+ * 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.
+ */
+package org.apache.kafka.clients.consumer;
+
+import org.apache.kafka.clients.producer.Producer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.record.TimestampType;
+import org.apache.kafka.common.test.ClusterInstance;
+import org.apache.kafka.common.test.TestUtils;
+import org.apache.kafka.common.test.api.ClusterTest;
+import org.apache.kafka.common.test.api.ClusterTestDefaults;
+import org.apache.kafka.common.test.api.Type;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.BiConsumer;
+
+import static 
org.apache.kafka.clients.consumer.ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG;
+import static 
org.apache.kafka.clients.consumer.ConsumerConfig.GROUP_PROTOCOL_CONFIG;
+import static org.apache.kafka.clients.consumer.GroupProtocol.CLASSIC;
+import static org.apache.kafka.clients.consumer.GroupProtocol.CONSUMER;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@ClusterTestDefaults(
+    types = {Type.KRAFT},
+    brokers = 3
+)
+public class PlaintextConsumerCallbackTest {
+
+    private final ClusterInstance cluster;
+    private final String topic = "topic";
+    private final TopicPartition tp = new TopicPartition(topic, 0);
+
+    public PlaintextConsumerCallbackTest(ClusterInstance clusterInstance) {
+        this.cluster = clusterInstance;
+    }
+
+    @ClusterTest
+    public void 
testClassicConsumerRebalanceListenerAssignOnPartitionsAssigned() throws 
InterruptedException {

Review Comment:
   Could you please try to eliminate the duplicate code? for instance:
   ```java
       @ClusterTest
       public void 
testClassicConsumerRebalanceListenerAssignOnPartitionsAssigned() throws 
InterruptedException {
           testConsumerRebalanceListenerAssignOnPartitionsAssigned(CLASSIC);
       }
   
       @ClusterTest
       public void 
testAsyncConsumerRebalanceListenerAssignOnPartitionsAssigned() throws 
InterruptedException {
           testConsumerRebalanceListenerAssignOnPartitionsAssigned(CONSUMER);
       }
       
       private void 
testConsumerRebalanceListenerAssignOnPartitionsAssigned(GroupProtocol protocol) 
throws InterruptedException {
           try (var consumer = createConsumer(protocol)) {
               triggerOnPartitionsAssigned(tp, consumer, (executeConsumer, 
partitions) -> {
                   var e = assertThrows(IllegalStateException.class, () -> 
executeConsumer.assign(List.of(tp)));
                   assertEquals("Subscription to topics, partitions and pattern 
are mutually exclusive", e.getMessage());
               });
           }
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to