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?

有帮助吗?

解决方案

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>

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top