--- /dev/null
+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<String, String> 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();
+ }
+ }
+
+}
--- /dev/null
+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());
+ }
+}