문제

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