Alexandre A Barbosa
01/16/2023, 8:02 PM@KafkaListener
annotation and when I run the functional tests, I produce a protobuf topic message and the listener works properly to consume that message.
But my unit test need to test this method, and I am using this:
@Autowired
lateinit var ingestionListener: IngestionConsumerListener
to inject my listener and I want to test this method but without the Kafka in memory.
But the test is trying to load the Kafka because I am getting this:
Could not resolve placeholder 'ingestion.config.topic.name' in value "#{'${ingestion.config.topic.name}'}"
that is used in my implementation:
@KafkaListener(
id = "ingestionListener",
topics = ["#{'\${ingestion.config.topic.name}'}"],
groupId = "#{'\${ingestion.consumer.group.id}'}",
concurrency = "#{'\${ingestion.config.consumer.concurrency}'}"
)
fun consumeIngestion(ingestionHttpRequest: ConsumerRecord<String, IngestionHttpRequest.HttpRequest>)
I am trying to use this kind of solution for my first unit test using Kotlin and Kafka:
@EnableAutoConfiguration(exclude = [KafkaAutoConfiguration::class])
but I am still struggling with the error above…
Please any suggestion to fix that? How to test a kafka listener using Java/Kotlin without Kafka in memory?
Issue: FIXED! I only needed to add all properties necessary for the UT and Kafka is not necessary at memory