From 2ab23f9540afe042c2f6b30c0ab9ea988acacc82 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Thu, 22 Feb 2024 14:39:30 +0100 Subject: [PATCH] test: Simplified & Unified the Kafka-tests --- .../chat/backend/domain/ChatHomeServiceTest.java | 2 ++ .../implementation/kafka/KafkaTestUtils.java | 15 +-------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeServiceTest.java b/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeServiceTest.java index 004c35f7..858d03d3 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeServiceTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/domain/ChatHomeServiceTest.java @@ -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 diff --git a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java index 52a527d3..2ede2029 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java +++ b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaTestUtils.java @@ -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(); - } } -- 2.20.1