I need an embedded kafka for unit testing(UT) purposes.
I am trying to get kafka-junit/kafka-junit5 at master · salesforce/kafka-junit · GitHub to work with Kotlin.
companion object {
/**
* gleefully stolen from: https://github.com/salesforce/kafka-junit/tree/master/kafka-junit5
*
* We have a single embedded Kafka server that gets started when this test class is initialized.
*
* It's automatically started before any methods are run via the @RegisterExtension annotation.
* It's automatically stopped after all of the tests are completed via the @RegisterExtension annotation.
*/
@JvmField
@RegisterExtension
var sharedKafkaTestResource: SharedKafkaTestResource = SharedKafkaTestResource().withBrokers(2)
}
but the BeforeAllCallback#beforeAll
, AfterAllCallback#afterAll
methods never get invoked.
- how can i get kafka-junit5 to work, or
- is there another embedded kafka solution that already works with kotlin?
here’s my pom:
<properties>
... snip ...
<salesforce-kafka-junit.version>3.1.0</salesforce-kafka-junit.version>
<salesforce-kafka.version>1.1.1</salesforce-kafka.version>
<junit-jupiter.version>5.3.2</junit-jupiter.version>
<kotlin.version>1.2.71</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.salesforce.kafka.test</groupId>
<artifactId>kafka-junit5</artifactId>
<version>${salesforce-kafka-junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.salesforce.kafka.test</groupId>
<artifactId>kafka-junit-core</artifactId>
<version>${salesforce-kafka-junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>${salesforce-kafka.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>${salesforce-kafka.version}</version>
</dependency>
... snip ...
</dependencies>