Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kafka jar does not include kafka.utils.testutils

I am trying to write a unit test test case for kafka producer/consumer and came across a simple example http://grokbase.com/t/kafka/users/13ck94p302/writing-unit-tests-for-kafka-code.

On using this code I figured the jar does not have Testutils class. I started some research on how to include this and find out that apache doesnot ship Testutils with the jar. I do not understand the reason. Then found this https://issues.apache.org/jira/browse/KAFKA-1308 which asks me to run some gradle commands.
I am confused. Why do I need to do that? Is there a simpler way to write this unit test or include Testutils ?

like image 759
change Avatar asked Aug 08 '14 03:08

change


2 Answers

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.11</artifactId>
    <version>0.8.2.1</version>
    <classifier>test</classifier>
</dependency>
like image 69
Ben Tse Avatar answered Nov 16 '22 18:11

Ben Tse


In general, you don't include test utilities in the main production jar. This pollutes the main code with test code which is unnecessary and bloats the most frequently used jar.

Try to find a separate kafka test jar or dependency and include that in your build system and you should be able to use the TestUtils class.

like image 34
laughing_man Avatar answered Nov 16 '22 18:11

laughing_man