From: Kai Moritz Date: Fri, 15 Sep 2023 09:42:32 +0000 (+0200) Subject: WIP:ALIGN X-Git-Tag: rebase--2023-09-15--16-33~16 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=a606ef21b4b26526fae6cc6da6006981861a54a8;p=demos%2Fkafka%2Fchat WIP:ALIGN --- diff --git a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java index f12775ab..1f7ec4d7 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java +++ b/src/test/java/de/juplo/kafka/chat/backend/implementation/kafka/KafkaChatHomeServiceTest.java @@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Import; import org.springframework.kafka.core.KafkaTemplate; import org.springframework.kafka.test.context.EmbeddedKafka; @@ -19,6 +18,7 @@ import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServ @SpringBootTest( classes = { + KafkaTestUtils.KafkaTestConfiguration.class, KafkaAutoConfiguration.class, TaskExecutionAutoConfiguration.class, }, @@ -27,7 +27,6 @@ import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServ "chat.backend.kafka.data-channel-topic=" + DATA_TOPIC, "chat.backend.kafka.num-partitions=" + NUM_SHARDS, }) -@Import(KafkaTestUtils.class) @EmbeddedKafka( topics = { INFO_TOPIC, DATA_TOPIC }, partitions = 10) 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 52727290..8d948efc 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 @@ -19,35 +19,38 @@ import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServ import static de.juplo.kafka.chat.backend.implementation.kafka.KafkaChatHomeServiceTest.INFO_TOPIC; -@TestConfiguration -@Import(KafkaServicesConfiguration.class) -@EnableConfigurationProperties(ChatBackendProperties.class) -@TestPropertySource(properties = { - "spring.main.allow-bean-definition-overriding=true", - "chat.backend.services=kafka", - "chat.backend.kafka.client-id-PREFIX=TEST", - "chat.backend.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}", - "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}", -}) @Slf4j public abstract class KafkaTestUtils { - @Bean - WorkAssignor dataChannelWorkAssignor(DataChannel dataChannel) + @TestConfiguration + @Import(KafkaServicesConfiguration.class) + @EnableConfigurationProperties(ChatBackendProperties.class) + @TestPropertySource(properties = { + "spring.main.allow-bean-definition-overriding=true", + "chat.backend.services=kafka", + "chat.backend.kafka.client-id-PREFIX=TEST", + "chat.backend.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}", + "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}", + }) + public static class KafkaTestConfiguration { - return consumer -> + @Bean + WorkAssignor dataChannelWorkAssignor(DataChannel dataChannel) { - List assignedPartitions = - List.of(new TopicPartition(DATA_TOPIC, 2)); - consumer.assign(assignedPartitions); - dataChannel.onPartitionsAssigned(assignedPartitions); - }; - } + return consumer -> + { + List assignedPartitions = + List.of(new TopicPartition(DATA_TOPIC, 2)); + consumer.assign(assignedPartitions); + dataChannel.onPartitionsAssigned(assignedPartitions); + }; + } - @Bean - Clock clock() - { - return Clock.systemDefaultZone(); + @Bean + Clock clock() + { + return Clock.systemDefaultZone(); + } }