Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kafka producer unit test (java)

Doing my first steps with kafka (java code) I would like to create a simple test for kafka producer, something like this where I can mock zoo keeper (this implementation looks nice but I can't reach some of the classes there, specifically EmbeddedZookeeper and TestUtils).

Any ideas?

like image 369
forhas Avatar asked Oct 08 '13 09:10

forhas


2 Answers

You can use the Kafka-test artifact:

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.9.2</artifactId>
    <version>0.8.0</version>
    <classifier>test</classifier>
    <scope>test</scope>
</dependency>

If you need a separate mock for zookeeper, Apache curator-test might do:

<dependency>
    <groupId>org.apache.curator</groupId>
    <version>2.3.2-SNAPSHOT</version>
    <artifactId>curator-test</artifactId>
    <scope>test</scope>
</dependency>
like image 143
teu Avatar answered Oct 03 '22 10:10

teu


Probably taken from the Kafka source .. Check here for EmbeddedZk and here for the Utils ..

The full package is available here

see if it helps

like image 31
user2720864 Avatar answered Oct 03 '22 11:10

user2720864