From 9ef2abbd01c676e41c35550b07892a46f60f0ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Mon, 30 Sep 2024 17:35:56 -0600 Subject: [PATCH] Use org.testcontainers.kafka.KafkaContainer --- .../consumer/SpringBootKafkaAvroGenericRecordTest.java | 8 +++----- .../com/example/consumer/SpringBootKafkaAvroTest.java | 8 +++----- .../SpringBootKafkaProtoBufDynamicMessageTest.java | 8 +++----- .../com/example/consumer/SpringBootKafkaProtoBufTest.java | 8 +++----- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroGenericRecordTest.java b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroGenericRecordTest.java index eb1b150..160bc38 100644 --- a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroGenericRecordTest.java +++ b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroGenericRecordTest.java @@ -13,12 +13,11 @@ import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.core.KafkaTemplate; import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.kafka.KafkaContainer; import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; import java.time.Duration; import java.util.ArrayList; @@ -41,9 +40,8 @@ public class SpringBootKafkaAvroGenericRecordTest { @Container @ServiceConnection - static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.3.0")) - .withNetwork(network) - .withListener(() -> "kafka:19092"); + static KafkaContainer kafka = new KafkaContainer("apache/kafka-native:3.8.0").withNetwork(network) + .withListener("kafka:19092"); @Container static GenericContainer schemaRegistry = new GenericContainer<>("confluentinc/cp-schema-registry:7.4.0") diff --git a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroTest.java b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroTest.java index da69d27..47fd350 100644 --- a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroTest.java +++ b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaAvroTest.java @@ -16,8 +16,7 @@ import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.containers.KafkaContainer; -import org.testcontainers.utility.DockerImageName; +import org.testcontainers.kafka.KafkaContainer; import java.time.Duration; import java.util.ArrayList; @@ -41,9 +40,8 @@ public class SpringBootKafkaAvroTest { @Container @ServiceConnection - static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.3.0")) - .withNetwork(network) - .withListener(() -> "kafka:19092"); + static KafkaContainer kafka = new KafkaContainer("apache/kafka-native:3.8.0").withNetwork(network) + .withListener("kafka:19092"); @Container static GenericContainer schemaRegistry = new GenericContainer<>("confluentinc/cp-schema-registry:7.4.0") diff --git a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufDynamicMessageTest.java b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufDynamicMessageTest.java index df4bb4c..4ab0e5c 100644 --- a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufDynamicMessageTest.java +++ b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufDynamicMessageTest.java @@ -14,12 +14,11 @@ import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.core.KafkaTemplate; import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.kafka.KafkaContainer; import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; import java.time.Duration; import java.util.ArrayList; @@ -42,9 +41,8 @@ public class SpringBootKafkaProtoBufDynamicMessageTest { @Container @ServiceConnection - static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.3.0")) - .withNetwork(network) - .withListener(() -> "kafka:19092"); + static KafkaContainer kafka = new KafkaContainer("apache/kafka-native:3.8.0").withNetwork(network) + .withListener("kafka:19092"); @Container static GenericContainer schemaRegistry = new GenericContainer<>("confluentinc/cp-schema-registry:7.4.0") diff --git a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufTest.java b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufTest.java index da16860..923d8e8 100644 --- a/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufTest.java +++ b/spring-boot-kafka/src/test/java/com/example/consumer/SpringBootKafkaProtoBufTest.java @@ -13,12 +13,11 @@ import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.core.KafkaTemplate; import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.KafkaContainer; +import org.testcontainers.kafka.KafkaContainer; import org.testcontainers.containers.Network; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.utility.DockerImageName; import java.time.Duration; import java.util.ArrayList; @@ -41,9 +40,8 @@ public class SpringBootKafkaProtoBufTest { @Container @ServiceConnection - static KafkaContainer kafka = new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:7.3.0")) - .withNetwork(network) - .withListener(() -> "kafka:19092"); + static KafkaContainer kafka = new KafkaContainer("apache/kafka-native:3.8.0").withNetwork(network) + .withListener("kafka:19092"); @Container static GenericContainer schemaRegistry = new GenericContainer<>("confluentinc/cp-schema-registry:7.4.0")