Class KafkaTestClient

java.lang.Object
com.bakdata.kafka.KafkaTestClient

public class KafkaTestClient extends Object
Client that supports communication with Kafka clusters in test setups, including topic management, reading from and sending to topics.
  • Constructor Details

  • Method Details

    • defaultTopicSettings

      public static TopicSettings.TopicSettingsBuilder defaultTopicSettings()
      Create a new TopicSettings.TopicSettingsBuilder which uses a single partition and no replicas
      Returns:
      default topic settings
    • send

      public <K, V> SenderBuilder<K,V> send()
      Prepare sending new data to the cluster
      Returns:
      configured SenderBuilder
    • read

      public <K, V> ReaderBuilder<K,V> read()
      Prepare reading data from the cluster. ConsumerConfig.AUTO_OFFSET_RESET_CONFIG is configured to AutoOffsetResetStrategy.EARLIEST
      Returns:
      configured ReaderBuilder
    • admin

      public AdminClientX admin()
      Create a new AdminClientX for the cluster
      Returns:
      configured admin client
    • createTopic

      public void createTopic(String topicName, TopicSettings settings, Map<String,String> config)
      Creates a new Kafka topic with the specified settings.
      Parameters:
      topicName - the topic name
      settings - settings for number of partitions and replicationFactor
      config - topic configuration
    • createTopic

      public void createTopic(String topicName, TopicSettings settings)
      Creates a new Kafka topic with the specified settings. No configs are used.
      Parameters:
      topicName - the topic name
      settings - settings for number of partitions and replicationFactor
      See Also:
    • createTopic

      public void createTopic(String topicName)
      Creates a new Kafka topic with default settings.
      Parameters:
      topicName - the topic name
      See Also:
    • existsTopic

      public boolean existsTopic(String topicName)
      Checks whether a Kafka topic exists.
      Parameters:
      topicName - the topic name
      Returns:
      whether a Kafka topic with the specified name exists or not