@Test
public void test() throws IOException {
Pusher pusher = new KafkaKeyValueProducerPusher<byte[], byte[]>("localhost:dummy", TOPIC,
Optional.of(ConfigFactory.parseMap(ImmutableMap.of(
ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:" + this.kafkaTestHelper.getKafkaServerPort()))));
String msg1 = "msg1";
String msg2 = "msg2";
pusher.pushMessages(Lists.newArrayList(Pair.of("key1", msg1.getBytes()), Pair.of("key2", msg2.getBytes())));
try {
Thread.sleep(1000);
} catch(InterruptedException ex) {
Thread.currentThread().interrupt();
}
ConsumerIterator<byte[], byte[]> iterator = this.kafkaTestHelper.getIteratorForTopic(TOPIC);
assert(iterator.hasNext());
MessageAndMetadata<byte[], byte[]> messageAndMetadata = iterator.next();
Assert.assertEquals(new String(messageAndMetadata.key()), "key1");
Assert.assertEquals(new String(messageAndMetadata.message()), msg1);
assert(iterator.hasNext());
messageAndMetadata = iterator.next();
Assert.assertEquals(new String(messageAndMetadata.key()), "key2");
Assert.assertEquals(new String(messageAndMetadata.message()), msg2);
pusher.close();
}