DirtiesContext does not close Kafka consumer and producer

Viewed 251

I'm trying to test a KafkaStreams application.Using JUnit5 and EmbededKafka. When executing any TestCase, I see that the logs are bombarded with the following messages

[Producer clientId=myTask-227e2e90-212b-4663-bd17-2d307018c81a-StreamThread-1-producer] Connection to node 0 (localhost/127.0.0.1:61269) could not be established. Broker may not be available.
[Consumer clientId=myTask-227e2e90-212b-4663-bd17-2d307018c81a-StreamThread-3-consumer, groupId=my-task] Connection to node 0 (localhost/127.0.0.1:61269) could not be established. Broker may not be available.

I have also added

@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)

Class Level configurations

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
@TestPropertySource("/application-test.properties")
@EmbeddedKafka(topics = { "${kafka.topic.}"
    },
    partitions = 1, controlledShutdown = true
)
@ExtendWith(MockitoExtension.class)
public class KStreamTest{

    @Autowired
 protected EmbeddedKafkaBroker embeddedKafka;
  
  //TestMethod

 }

Can you suggest anything I can try or if I'm missing something?

0 Answers
Related