# spring

Alexandre A Barbosa

01/16/2023, 8:02 PM
Hi team. please: is it possible to disable Kafka during my unit tests? I’ve created a class with a method using
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:
Copy code
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:
Copy code
Could not resolve placeholder '' in value "#{'${}'}"
that is used in my implementation:
Copy code
    id = "ingestionListener",
    topics = ["#{'\${}'}"],
    groupId = "#{'\${}'}",
    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:
Copy code
@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