0

I would like to use MockAdminClient for unit testing my Kafka application. How can I make MockAdminClient imported using maven?

https://github.com/apache/kafka/blob/2.3.0/clients/src/test/java/org/apache/kafka/clients/admin/MockAdminClient.java

UPDATE:

My kafka-client related pom.xml

<dependency>
   <groupId>org.apache.kafka</groupId>
   <artifactId>kafka-clients</artifactId>
    <version>${kafka.version}</version>
</dependency>

By referring test by maven I found sth like this How can I reference unit test classes of a maven dependency in my java project?

HungUnicorn
  • 1,946
  • 2
  • 12
  • 28

2 Answers2

2

You need to pull the test classifier, and then add the test scope to get it only available for your unit tests

<dependency>
   <groupId>org.apache.kafka</groupId>
   <artifactId>kafka-clients</artifactId>
    <version>${kafka.version}</version>
    <scope>test</scope>
    <classifier>test</classifier>
</dependency>
OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
0

It is a part of Kafka Clients, you have to add the following dependency in maven pom.xml.

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>2.3.0</version>
</dependency>

For more dependencies, you can refer the below link. https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients

OneCricketeer
  • 126,858
  • 14
  • 92
  • 185
Sambit
  • 6,316
  • 4
  • 21
  • 54