Class MockConsumer<K,V>

java.lang.Object
org.apache.kafka.clients.consumer.MockConsumer<K,V>
All Implemented Interfaces:
Closeable, AutoCloseable, Consumer<K,V>

public class MockConsumer<K,V> extends Object implements Consumer<K,V>
A mock of the Consumer interface you can use for testing code that uses Kafka. This class is not threadsafe . However, you can use the schedulePollTask(Runnable) method to write multithreaded tests where a driver thread waits for poll(Duration) to be called by a background thread and then can safely perform operations during a callback.