TMP:test -- `ChatRoomDataTest`
[demos/kafka/chat] / src / test / java / de / juplo / kafka / chat / backend / implementation / kafka / KafkaChatHomeServiceTest.java
1 package de.juplo.kafka.chat.backend.implementation.kafka;
2
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;
13
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;
17
18
19 @ContextConfiguration(classes = {
20         KafkaTestUtils.KafkaTestConfiguration.class,
21         KafkaAutoConfiguration.class,
22         TaskExecutionAutoConfiguration.class,
23     })
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,
32 })
33 @EmbeddedKafka(
34     topics = { INFO_TOPIC, DATA_TOPIC },
35     partitions = NUM_SHARDS)
36 @Slf4j
37 public class KafkaChatHomeServiceTest extends ChatHomeServiceWithShardsTest
38 {
39   final static String INFO_TOPIC = "KAFKA_CHAT_HOME_TEST_INFO";
40   final static String DATA_TOPIC = "KAFKA_CHAT_HOME_TEST_DATA";
41
42
43   @BeforeAll
44   static void sendAndLoadStoredData(
45       @Autowired KafkaTemplate<String, String> messageTemplate)
46   {
47     KafkaTestUtils.sendAndLoadStoredData(
48         messageTemplate,
49         INFO_TOPIC,
50         DATA_TOPIC);
51   }
52 }