@Test(expected = org.apache.kafka.common.KafkaException.class) public void testWrongPID() {
    producer.initTransactions();
    producer.beginTransaction();
    short epoch = producer.getEpoch();
    producer.close(Duration.ZERO);
    HiveKafkaProducer secondProducer = new HiveKafkaProducer(producerProperties);
    secondProducer.resumeTransaction(45L, epoch);
    secondProducer.sendOffsetsToTransaction(ImmutableMap.of(), "__dummy_consumer_group");
    secondProducer.close(Duration.ZERO);
  }
Test class for Hive Kafka Producer.
kafka-handler/src/test/org/apache/hadoop/hive/kafka/HiveKafkaProducerTest.java