test: Simplified & Unified the Kafka-tests
authorKai Moritz <kai@juplo.de>
Thu, 22 Feb 2024 13:39:30 +0000 (14:39 +0100)
committerKai Moritz <kai@juplo.de>
Thu, 22 Feb 2024 15:08:03 +0000 (16:08 +0100)
src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeServiceTest.java
src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java

index 004c35f..858d03d 100644 (file)
@@ -4,6 +4,7 @@ import de.juplo.kafka.chat.backend.ChatBackendProperties;
 import de.juplo.kafka.chat.backend.domain.exceptions.LoadInProgressException;
 import de.juplo.kafka.chat.backend.domain.exceptions.UnknownChatroomException;
 import de.juplo.kafka.chat.backend.implementation.inmemory.InMemoryServicesConfiguration;
+import de.juplo.kafka.chat.backend.implementation.kafka.KafkaServicesConfiguration;
 import de.juplo.kafka.chat.backend.storage.files.FilesStorageConfiguration;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
@@ -24,6 +25,7 @@ import static pl.rzrz.assertj.reactor.Assertions.assertThat;
 @SpringJUnitConfig(classes = {
     InMemoryServicesConfiguration.class,
     FilesStorageConfiguration.class,
+    KafkaServicesConfiguration.class,
     ChatHomeServiceTest.TestConfiguration.class })
 @EnableConfigurationProperties(ChatBackendProperties.class)
 public abstract class ChatHomeServiceTest
index 52a527d..2ede202 100644 (file)
@@ -5,24 +5,17 @@ import de.juplo.kafka.chat.backend.domain.ShardingPublisherStrategy;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.kafka.clients.producer.ProducerRecord;
 import org.apache.kafka.common.TopicPartition;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.boot.test.context.TestConfiguration;
 import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Import;
 import org.springframework.kafka.core.KafkaTemplate;
 import org.springframework.kafka.support.SendResult;
 import reactor.core.publisher.Mono;
 
-import java.time.Clock;
 import java.util.List;
 
 
 @Slf4j
-public class KafkaTestUtils
+public abstract class KafkaTestUtils
 {
-  @TestConfiguration
-  @EnableConfigurationProperties(ChatBackendProperties.class)
-  @Import(KafkaServicesConfiguration.class)
   public static class KafkaTestConfiguration
   {
     @Bean
@@ -44,12 +37,6 @@ public class KafkaTestUtils
         dataChannel.onPartitionsAssigned(assignedPartitions);
       };
     }
-
-    @Bean
-    public Clock clock()
-    {
-      return Clock.systemDefaultZone();
-    }
   }