From: Kai Moritz Date: Fri, 5 Jul 2024 20:45:58 +0000 (+0200) Subject: Separated Demo-Tests from Example-Tests X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fdemos;p=demos%2Fkafka%2Fwordcount Separated Demo-Tests from Example-Tests --- diff --git a/pom.xml b/pom.xml index 091cc27..fdde5a9 100644 --- a/pom.xml +++ b/pom.xml @@ -12,15 +12,14 @@ de.juplo.kafka.streams.demos - examples + demos 1.0.0-SNAPSHOT - Examples - Examples for Kafka Streams + Demos + Demo Tests for Kafka Streams 21 - 0.44.0 diff --git a/src/test/java/de/juplo/kafka/wordcount/counter/SpringBootTestExampleTest.java b/src/test/java/de/juplo/kafka/wordcount/counter/SpringBootTestExampleTest.java deleted file mode 100644 index 8088427..0000000 --- a/src/test/java/de/juplo/kafka/wordcount/counter/SpringBootTestExampleTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package de.juplo.kafka.wordcount.counter; - -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.kafka.annotation.KafkaListener; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.support.KafkaHeaders; -import org.springframework.kafka.test.context.EmbeddedKafka; -import org.springframework.messaging.handler.annotation.Header; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.test.annotation.DirtiesContext; - - -@SpringBootTest -@EmbeddedKafka(topics = "TEST") -@DirtiesContext -@Slf4j -public class SpringBootTestExampleTest -{ - @Test - void testC( - @Autowired KafkaTemplate template, - @Autowired Consumer consumer) - { - template.send("TEST", "peter", "Hallo Welt!"); - } - - static class Consumer - { - @KafkaListener(groupId = "test", topics = "TEST") - public void receive( - @Header(KafkaHeaders.RECEIVED_KEY) String key, - @Payload String value) - { - log.info("Received {}={}", key, value); - } - } - - @TestConfiguration - static class Config - { - @Bean - Consumer consumer() - { - return new Consumer(); - } - } - -} diff --git a/src/test/java/de/juplo/kafka/wordcount/counter/SpringJunitConfigExampleTest.java b/src/test/java/de/juplo/kafka/wordcount/counter/SpringJunitConfigExampleTest.java deleted file mode 100644 index ae2b22e..0000000 --- a/src/test/java/de/juplo/kafka/wordcount/counter/SpringJunitConfigExampleTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package de.juplo.kafka.wordcount.counter; - -import lombok.extern.slf4j.Slf4j; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.test.EmbeddedKafkaBroker; -import org.springframework.kafka.test.context.EmbeddedKafka; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; - - -@SpringJUnitConfig -@EmbeddedKafka(topics = "TEST") -@DirtiesContext -@Slf4j -public class SpringJunitConfigExampleTest -{ - @Test - void testValue(@Value("${spring.embedded.kafka.brokers}") String brokers) - { - log.info("Broker-Adress: {}", brokers); - } - - @Test - void testEmbeddedKafkaBroker(@Autowired EmbeddedKafkaBroker broker) - { - log.info("Broker-Adress: {}", broker.getBrokersAsString()); - } -}