Pergunta

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?

Foi útil?

Solução

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>

Outras dicas

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top