From 416f33a006fef2b460a8c646e4dc168f462f7b2f Mon Sep 17 00:00:00 2001 From: Timon Back Date: Fri, 24 Nov 2023 13:15:24 +0100 Subject: [PATCH] test(kafka): ensure ProducerSystemTest can connect to kafka Without, the test connects to a kafka instance of a previous spring context instance - which is an embeddedkafka and not available --- .../springwolf/example/kafka/ProducerSystemTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java index 6a2bf7cd2..fc46ec712 100644 --- a/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java +++ b/springwolf-examples/springwolf-kafka-example/src/test/java/io/github/stavshamir/springwolf/example/kafka/ProducerSystemTest.java @@ -15,7 +15,7 @@ import org.springframework.boot.ssl.DefaultSslBundleRegistry; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; -import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.TestPropertySource; import org.testcontainers.containers.DockerComposeContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -39,7 +39,7 @@ classes = {SpringwolfKafkaExampleApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @Testcontainers -@DirtiesContext +@TestPropertySource(properties = {"spring.kafka.bootstrap-servers=localhost:9092"}) @TestMethodOrder(OrderAnnotation.class) // @Ignore("Uncomment this line if you have issues running this test on your local machine.") public class ProducerSystemTest {