You might take a look at the KafkaServerTestHarness [1] if you’re not already familiar with it. It’s not exactly “mock”, but it makes it easy to test Kafka functionality without needing to connect to any external broker or ZK processes. We ported this test harness to Java for our junit and integration tests, and use a junit suite to keep it running for all tests.
[1] https://github.com/apache/kafka/blob/trunk/core/src/test/scala/unit/kafka/integration/KafkaServerTestHarness.scala CONFIDENTIALITY NOTICE This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.