// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java
// @DataObject
// public class StringKafkaMessage extends AbstractKafkaMessage {
// 
//     private String payload;
// 
//     public StringKafkaMessage() {
//     }
// 
//     public StringKafkaMessage(String payload) {
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public StringKafkaMessage(String payload, String partKey) {
//         super(partKey);
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) {
//         super(stringKafkaMessage.getPartKey());
//         this.payload = stringKafkaMessage.getPayload();
//     }
// 
//     public StringKafkaMessage(JsonObject jsonObject) {
//         super(jsonObject.getString(PART_KEY));
//         this.payload = jsonObject.getString(PAYLOAD);
//     }
// 
//     public String getPayload() {
//         return payload;
//     }
// 
//     public void setPayload(String payload) {
//         this.payload = payload;
//     }
// 
//     public JsonObject toJson() {
//         final JsonObject jsonObject = super.asJson();
//         if (getPayload() != null) {
//             jsonObject.put(PAYLOAD, getPayload());
//         }
//         return jsonObject;
//     }
// }
// 
// Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java
// public final class KafkaProducerProperties {
// 
//     /* Non-instantiable class */
//     private KafkaProducerProperties() {}
// 
//     public static final String ADDRESS = "address";
//     public static final String BOOTSTRAP_SERVERS = "bootstrapServers";
//     public static final String ACKS = "acks";
//     public static final String DEFAULT_TOPIC = "defaultTopic";
//     public static final String TYPE = "type";
//     public static final String MAX_RETRIES = "maxRetries";
//     public static final String RETRY_BACKOFF_MS = "retryBackoffMs";
//     public static final String BUFFERING_MAX_MS = "bufferingMaxMs";
//     public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages";
//     public static final String ENQUEUE_TIMEOUT = "enqueueTimeout";
//     public static final String BATCH_MESSAGE_NUM = "batchMessageNum";
//     public static final String RETRIES = "retries";
//     public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs";
//     public static final String MAX_BLOCK_MS = "maxBlockMs";
//     public static final String STATSD = "statsD";
//     public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses";
//     public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName";
// 
//     public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092";
//     public static final String ACKS_DEFAULT = "1";
// 
//     public static final int RETRIES_DEFAULT = 0;
//     public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000;
//     public static final int MAX_BLOCK_MS_DEFAULT = 60000;
// 
// }


import com.google.common.collect.Lists;
import com.googlecode.junittoolbox.PollingWait;
import com.googlecode.junittoolbox.RunnableAssert;
import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage;
import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties;
import com.netflix.curator.test.TestingServer;
import io.vertx.core.AsyncResult;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import kafka.admin.AdminUtils;
import kafka.admin.RackAwareMode;
import kafka.consumer.ConsumerConfig;
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import kafka.javaapi.consumer.ConsumerConnector;
import kafka.serializer.StringDecoder;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import kafka.utils.TestUtils;
import kafka.utils.VerifiableProperties;
import kafka.utils.ZKStringSerializer$;
import kafka.utils.ZkUtils;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.ZkConnection;
import org.apache.kafka.common.security.auth.SecurityProtocol;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import scala.Option;
import scala.collection.JavaConversions;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

    private void startZookeeper() {
        try {
            zookeeper = new TestingServer();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void test(TestContext testContext) throws Exception {
        JsonObject config = new JsonObject();
        config.put(KafkaProducerProperties.ADDRESS, ADDRESS);
        config.put(KafkaProducerProperties.BOOTSTRAP_SERVERS, KafkaProducerProperties.BOOTSTRAP_SERVERS_DEFAULT);
        config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC);
        config.put(KafkaProducerProperties.ACKS, KafkaProducerProperties.ACKS_DEFAULT);

        final DeploymentOptions deploymentOptions = new DeploymentOptions();
        deploymentOptions.setConfig(config);
        deploy(testContext, deploymentOptions);

        final Async async = testContext.async();
        try {
            shouldReceiveMessage(testContext, async);
        } catch (Exception e) {
            testContext.fail(e);
        }
    }

    public void shouldReceiveMessage(TestContext testContext, Async async) throws Exception {
// Path: src/main/java/com/hubrick/vertx/kafka/producer/model/StringKafkaMessage.java
// @DataObject
// public class StringKafkaMessage extends AbstractKafkaMessage {
// 
//     private String payload;
// 
//     public StringKafkaMessage() {
//     }
// 
//     public StringKafkaMessage(String payload) {
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public StringKafkaMessage(String payload, String partKey) {
//         super(partKey);
//         checkNotNull(payload, "payload must not be null");
// 
//         this.payload = payload;
//     }
// 
//     public StringKafkaMessage(StringKafkaMessage stringKafkaMessage) {
//         super(stringKafkaMessage.getPartKey());
//         this.payload = stringKafkaMessage.getPayload();
//     }
// 
//     public StringKafkaMessage(JsonObject jsonObject) {
//         super(jsonObject.getString(PART_KEY));
//         this.payload = jsonObject.getString(PAYLOAD);
//     }
// 
//     public String getPayload() {
//         return payload;
//     }
// 
//     public void setPayload(String payload) {
//         this.payload = payload;
//     }
// 
//     public JsonObject toJson() {
//         final JsonObject jsonObject = super.asJson();
//         if (getPayload() != null) {
//             jsonObject.put(PAYLOAD, getPayload());
//         }
//         return jsonObject;
//     }
// }
// 
// Path: src/main/java/com/hubrick/vertx/kafka/producer/property/KafkaProducerProperties.java
// public final class KafkaProducerProperties {
// 
//     /* Non-instantiable class */
//     private KafkaProducerProperties() {}
// 
//     public static final String ADDRESS = "address";
//     public static final String BOOTSTRAP_SERVERS = "bootstrapServers";
//     public static final String ACKS = "acks";
//     public static final String DEFAULT_TOPIC = "defaultTopic";
//     public static final String TYPE = "type";
//     public static final String MAX_RETRIES = "maxRetries";
//     public static final String RETRY_BACKOFF_MS = "retryBackoffMs";
//     public static final String BUFFERING_MAX_MS = "bufferingMaxMs";
//     public static final String BUFFERING_MAX_MESSAGES = "bufferingMaxMessages";
//     public static final String ENQUEUE_TIMEOUT = "enqueueTimeout";
//     public static final String BATCH_MESSAGE_NUM = "batchMessageNum";
//     public static final String RETRIES = "retries";
//     public static final String REQUEST_TIMEOUT_MS = "requestTimeoutMs";
//     public static final String MAX_BLOCK_MS = "maxBlockMs";
//     public static final String STATSD = "statsD";
//     public static final String METRIC_CONSUMER_CLASSES = "metricConsumerClasses";
//     public static final String METRIC_DROPWIZARD_REGISTRY_NAME = "metricDropwizardRegistryName";
// 
//     public static final String BOOTSTRAP_SERVERS_DEFAULT = "localhost:9092";
//     public static final String ACKS_DEFAULT = "1";
// 
//     public static final int RETRIES_DEFAULT = 0;
//     public static final int REQUEST_TIMEOUT_MS_DEFAULT = 30000;
//     public static final int MAX_BLOCK_MS_DEFAULT = 60000;
// 
// }


// Path: src/test/java/com/hubrick/vertx/kafka/producer/KafkaProducerServiceIntegrationTest.java
import com.google.common.collect.Lists;
import com.googlecode.junittoolbox.PollingWait;
import com.googlecode.junittoolbox.RunnableAssert;
import com.hubrick.vertx.kafka.producer.model.StringKafkaMessage;
import com.hubrick.vertx.kafka.producer.property.KafkaProducerProperties;
import com.netflix.curator.test.TestingServer;
import io.vertx.core.AsyncResult;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Handler;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.unit.Async;
import io.vertx.ext.unit.TestContext;
import io.vertx.ext.unit.junit.VertxUnitRunner;
import kafka.admin.AdminUtils;
import kafka.admin.RackAwareMode;
import kafka.consumer.ConsumerConfig;
import kafka.consumer.ConsumerIterator;
import kafka.consumer.KafkaStream;
import kafka.javaapi.consumer.ConsumerConnector;
import kafka.serializer.StringDecoder;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import kafka.utils.TestUtils;
import kafka.utils.VerifiableProperties;
import kafka.utils.ZKStringSerializer$;
import kafka.utils.ZkUtils;
import org.I0Itec.zkclient.ZkClient;
import org.I0Itec.zkclient.ZkConnection;
import org.apache.kafka.common.security.auth.SecurityProtocol;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import scala.Option;
import scala.collection.JavaConversions;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;


    private void startZookeeper() {
        try {
            zookeeper = new TestingServer();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Test
    public void test(TestContext testContext) throws Exception {
        JsonObject config = new JsonObject();
        config.put(KafkaProducerProperties.ADDRESS, ADDRESS);
        config.put(KafkaProducerProperties.BOOTSTRAP_SERVERS, KafkaProducerProperties.BOOTSTRAP_SERVERS_DEFAULT);
        config.put(KafkaProducerProperties.DEFAULT_TOPIC, TOPIC);
        config.put(KafkaProducerProperties.ACKS, KafkaProducerProperties.ACKS_DEFAULT);

        final DeploymentOptions deploymentOptions = new DeploymentOptions();
        deploymentOptions.setConfig(config);
        deploy(testContext, deploymentOptions);

        final Async async = testContext.async();
        try {
            shouldReceiveMessage(testContext, async);
        } catch (Exception e) {
            testContext.fail(e);
        }
    }

    public void shouldReceiveMessage(TestContext testContext, Async async) throws Exception {
        final StringKafkaMessage stringKafkaMessage = new StringKafkaMessage("foobar", "bar");