1 package de.juplo.kafka.chat.backend.implementation.kafka;
3 import de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest;
4 import lombok.extern.slf4j.Slf4j;
5 import org.junit.jupiter.api.BeforeAll;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration;
8 import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
9 import org.springframework.kafka.core.KafkaTemplate;
10 import org.springframework.kafka.test.context.EmbeddedKafka;
11 import org.springframework.test.context.ContextConfiguration;
12 import org.springframework.test.context.TestPropertySource;
14 import static de.juplo.kafka.chat.backend.domain.ChatHomeServiceWithShardsTest.NUM_SHARDS;
15 import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServiceTest.DATA_TOPIC;
16 import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServiceTest.INFO_TOPIC;
19 @ContextConfiguration(classes = {
20 KafkaTestUtils.KafkaTestConfiguration.class,
21 KafkaAutoConfiguration.class,
22 TaskExecutionAutoConfiguration.class,
24 @TestPropertySource(properties = {
25 "chat.backend.services=kafka",
26 "chat.backend.kafka.client-id-PREFIX=TEST",
27 "chat.backend.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
28 "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
29 "chat.backend.kafka.info-channel-topic=" + INFO_TOPIC,
30 "chat.backend.kafka.data-channel-topic=" + DATA_TOPIC,
31 "chat.backend.kafka.num-partitions=" + NUM_SHARDS,
34 topics = { INFO_TOPIC, DATA_TOPIC },
35 partitions = NUM_SHARDS)
37 public class KafkaChatHomeServiceTest extends ChatHomeServiceWithShardsTest
39 final static String INFO_TOPIC = "KAFKA_CHAT_HOME_TEST_INFO";
40 final static String DATA_TOPIC = "KAFKA_CHAT_HOME_TEST_DATA";
44 static void sendAndLoadStoredData(
45 @Autowired KafkaTemplate<String, String> messageTemplate)
47 KafkaTestUtils.sendAndLoadStoredData(