NEU
authorKai Moritz <kai@juplo.de>
Thu, 20 Apr 2023 12:35:22 +0000 (14:35 +0200)
committerKai Moritz <kai@juplo.de>
Thu, 20 Apr 2023 12:35:22 +0000 (14:35 +0200)
src/test/java/de/juplo/kafka/chat/backend/KafkaConfigurationIT.java

index e300c0d..822f530 100644 (file)
@@ -9,7 +9,8 @@ import org.springframework.kafka.test.context.EmbeddedKafka;
 
 import java.util.UUID;
 
-import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.TOPIC;
+import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.CHATROOMS_TOPIC;
+import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.MESSAGES_TOPIC;
 
 
 @SpringBootTest(
@@ -19,12 +20,14 @@ import static de.juplo.kafka.chat.backend.KafkaConfigurationIT.TOPIC;
         "chat.backend.kafka.client-id=TEST",
         "chat.backend.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
         "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
-        "chat.backend.kafka.topic=" + TOPIC,
+        "chat.backend.kafka.chatrooms-topic=" + CHATROOMS_TOPIC,
+        "chat.backend.kafka.messages-topic=" + MESSAGES_TOPIC,
         "chat.backend.kafka.num-partitions=3" })
-@EmbeddedKafka(topics = TOPIC, partitions = 3)
+@EmbeddedKafka(topics = { CHATROOMS_TOPIC, MESSAGES_TOPIC }, partitions = 3)
 class KafkaConfigurationIT extends AbstractConfigurationIT
 {
-  final static String TOPIC = "TEST";
+  final static String CHATROOMS_TOPIC = "TEST_CHAT_ROOMS";
+  final static String MESSAGES_TOPIC = "TEST_CHAT_MESSAGES";
 
   @BeforeAll
   public static void test(
@@ -34,10 +37,10 @@ class KafkaConfigurationIT extends AbstractConfigurationIT
   {
     UUID chatRoomId = UUID.fromString("5c73531c-6fc4-426c-adcb-afc5c140a0f7");
     int shard = shardingStrategy.selectShard(chatRoomId);
-    chatRoomTemplate.send(TOPIC, null,"{ \"id\": \"5c73531c-6fc4-426c-adcb-afc5c140a0f7\", \"shard\": " + shard + ", \"name\": \"FOO\" }");
-    messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"peter\", \"text\" : \"Hallo, ich heiße Peter!\" }");
-    messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"ute\", \"text\" : \"Ich bin Ute...\" }");
-    messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 2, \"user\" : \"peter\", \"text\" : \"Willst du mit mir gehen?\" }");
-    messageTemplate.send(TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"klaus\", \"text\" : \"Ja? Nein? Vielleicht??\" }");
+    chatRoomTemplate.send(CHATROOMS_TOPIC, null,"{ \"id\": \"5c73531c-6fc4-426c-adcb-afc5c140a0f7\", \"shard\": " + shard + ", \"name\": \"FOO\" }");
+    messageTemplate.send(MESSAGES_TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"peter\", \"text\" : \"Hallo, ich heiße Peter!\" }");
+    messageTemplate.send(MESSAGES_TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"ute\", \"text\" : \"Ich bin Ute...\" }");
+    messageTemplate.send(MESSAGES_TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 2, \"user\" : \"peter\", \"text\" : \"Willst du mit mir gehen?\" }");
+    messageTemplate.send(MESSAGES_TOPIC,"5c73531c-6fc4-426c-adcb-afc5c140a0f7","{ \"id\" : 1, \"user\" : \"klaus\", \"text\" : \"Ja? Nein? Vielleicht??\" }");
   }
 }