protected void fillKafkaToConfig(MJob job) {
   MConfigList toConfig = job.getToJobConfig();
   toConfig.getStringInput("toJobConfig.topic").setValue(topic);
   List<String> topics = new ArrayList<String>(1);
   topics.add(topic);
   testUtil.initTopicList(topics);
 }
  /**
   * Compare strings in content to the messages in Kafka topic
   *
   * @param content
   * @throws UnsupportedEncodingException
   */
  protected void validateContent(String[] content) throws UnsupportedEncodingException {

    Set<String> inputSet = new HashSet<String>(Arrays.asList(content));
    Set<String> outputSet = new HashSet<String>();

    for (String str : content) {
      MessageAndMetadata<byte[], byte[]> fetchedMsg = testUtil.getNextMessageFromConsumer(topic);
      outputSet.add(toText(new String(fetchedMsg.message(), "UTF-8")));
    }

    Assert.assertEquals(inputSet, outputSet);
  }
public class KafkaConnectorTestCase extends ConnectorTestCase {
  private static TestUtil testUtil = TestUtil.getInstance();
  protected String topic;

  @BeforeClass(alwaysRun = true)
  public void startKafka() throws Exception {
    // starts Kafka server and its dependent zookeeper
    testUtil.prepare();
  }

  @AfterClass(alwaysRun = true)
  public void stopKafka() throws IOException {
    testUtil.tearDown();
  }

  protected void fillKafkaLinkConfig(MLink link) {
    MConfigList configs = link.getConnectorLinkConfig();
    configs.getStringInput("linkConfig.brokerList").setValue(testUtil.getKafkaServerUrl());
    configs.getStringInput("linkConfig.zookeeperConnect").setValue(testUtil.getZkUrl());
  }

  protected void fillKafkaToConfig(MJob job) {
    MConfigList toConfig = job.getToJobConfig();
    toConfig.getStringInput("toJobConfig.topic").setValue(topic);
    List<String> topics = new ArrayList<String>(1);
    topics.add(topic);
    testUtil.initTopicList(topics);
  }

  /**
   * Compare strings in content to the messages in Kafka topic
   *
   * @param content
   * @throws UnsupportedEncodingException
   */
  protected void validateContent(String[] content) throws UnsupportedEncodingException {

    Set<String> inputSet = new HashSet<String>(Arrays.asList(content));
    Set<String> outputSet = new HashSet<String>();

    for (String str : content) {
      MessageAndMetadata<byte[], byte[]> fetchedMsg = testUtil.getNextMessageFromConsumer(topic);
      outputSet.add(toText(new String(fetchedMsg.message(), "UTF-8")));
    }

    Assert.assertEquals(inputSet, outputSet);
  }
}
 protected void fillKafkaLinkConfig(MLink link) {
   MConfigList configs = link.getConnectorLinkConfig();
   configs.getStringInput("linkConfig.brokerList").setValue(testUtil.getKafkaServerUrl());
   configs.getStringInput("linkConfig.zookeeperConnect").setValue(testUtil.getZkUrl());
 }
 @AfterClass(alwaysRun = true)
 public void stopKafka() throws IOException {
   testUtil.tearDown();
 }
 @BeforeClass(alwaysRun = true)
 public void startKafka() throws Exception {
   // starts Kafka server and its dependent zookeeper
   testUtil.prepare();
 }