Springify: GRÜN - `start()`/`stop()` werden im Test explizit aufgerufen
authorKai Moritz <kai@juplo.de>
Fri, 15 Apr 2022 09:51:08 +0000 (11:51 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 15 Apr 2022 11:57:09 +0000 (13:57 +0200)
src/test/java/de/juplo/kafka/ApplicationTests.java

index cbf215e..35d2b2e 100644 (file)
@@ -67,6 +67,8 @@ class ApplicationTests
        @Autowired
        ApplicationProperties properties;
        @Autowired
+       EndlessConsumer endlessConsumer;
+       @Autowired
        RecordHandler recordHandler;
 
        Map<TopicPartition, Long> oldOffsets;
@@ -224,8 +226,22 @@ class ApplicationTests
                                        newOffsets.put(
                                                        new TopicPartition(record.topic(), record.partition()),
                                                        record.offset());
+
+               endlessConsumer.start();
        }
 
+       @AfterEach
+       public void deinit()
+       {
+               try
+               {
+                       endlessConsumer.stop();
+               }
+               catch (Exception e)
+               {
+                       log.info("Exception while stopping the consumer: {}", e.toString());
+               }
+       }
 
        public static class RecordHandler implements Consumer<ConsumerRecord<String, Long>>
        {