Class KafkaContainer

java.lang.Object
org.testcontainers.containers.FailureDetectingExternalResource
org.testcontainers.containers.GenericContainer<KafkaContainer>
org.testcontainers.containers.KafkaContainer
All Implemented Interfaces:
AutoCloseable, org.junit.rules.TestRule, org.testcontainers.containers.Container<KafkaContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

@Deprecated public class KafkaContainer extends org.testcontainers.containers.GenericContainer<KafkaContainer>
Deprecated.
Testcontainers implementation for Apache Kafka. Zookeeper can be optionally configured.

Supported image: confluentinc/cp-kafka

Exposed ports:

  • Kafka: 9093
  • Zookeeper: 2181
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.testcontainers.containers.Container

    org.testcontainers.containers.Container.ExecResult
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Deprecated.
     
    protected String
    Deprecated.
     
    static final int
    Deprecated.
     
    static final int
    Deprecated.
     

    Fields inherited from class org.testcontainers.containers.GenericContainer

    CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategy

    Fields inherited from interface org.testcontainers.containers.ContainerState

    STATE_HEALTHY
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    KafkaContainer(String confluentPlatformVersion)
    Deprecated.
    KafkaContainer(org.testcontainers.utility.DockerImageName dockerImageName)
    Deprecated.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    brokerAdvertisedListener(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
    Deprecated.
     
    protected String
    Deprecated.
     
    protected String
    Deprecated.
     
    protected void
    Deprecated.
     
    protected void
    Deprecated.
     
    protected void
    Deprecated.
     
    protected void
    containerIsStarting(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
    Deprecated.
     
    Deprecated.
     
    withClusterId(String clusterId)
    Deprecated.
     
    Deprecated.
     
    Deprecated.
     
    Deprecated.
     
    withListener(Supplier<String> listenerSupplier)
    Deprecated.
    Add a Supplier that will provide a listener with format host:port.

    Methods inherited from class org.testcontainers.containers.GenericContainer

    addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectory

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.testcontainers.containers.Container

    addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBind

    Methods inherited from interface org.testcontainers.containers.ContainerState

    copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning

    Methods inherited from interface org.testcontainers.lifecycle.Startable

    close
  • Field Details

    • KAFKA_PORT

      public static final int KAFKA_PORT
      Deprecated.
      See Also:
    • ZOOKEEPER_PORT

      public static final int ZOOKEEPER_PORT
      Deprecated.
      See Also:
    • DEFAULT_CLUSTER_ID

      public static final String DEFAULT_CLUSTER_ID
      Deprecated.
      See Also:
    • externalZookeeperConnect

      protected String externalZookeeperConnect
      Deprecated.
  • Constructor Details

  • Method Details

    • withEmbeddedZookeeper

      public KafkaContainer withEmbeddedZookeeper()
      Deprecated.
    • withExternalZookeeper

      public KafkaContainer withExternalZookeeper(String connectString)
      Deprecated.
    • withKraft

      public KafkaContainer withKraft()
      Deprecated.
    • withClusterId

      public KafkaContainer withClusterId(String clusterId)
      Deprecated.
    • getBootstrapServers

      public String getBootstrapServers()
      Deprecated.
    • configure

      protected void configure()
      Deprecated.
      Overrides:
      configure in class org.testcontainers.containers.GenericContainer<KafkaContainer>
    • configureKraft

      protected void configureKraft()
      Deprecated.
    • configureZookeeper

      protected void configureZookeeper()
      Deprecated.
    • containerIsStarting

      protected void containerIsStarting(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
      Deprecated.
      Overrides:
      containerIsStarting in class org.testcontainers.containers.GenericContainer<KafkaContainer>
    • commandKraft

      protected String commandKraft()
      Deprecated.
    • commandZookeeper

      protected String commandZookeeper()
      Deprecated.
    • withListener

      public KafkaContainer withListener(Supplier<String> listenerSupplier)
      Deprecated.
      Add a Supplier that will provide a listener with format host:port. Host will be added as a network alias.

      The listener will be added to the list of default listeners.

      Default listeners:

      • 0.0.0.0:9092
      • 0.0.0.0:9093

      Default advertised listeners:

      • container.getHost():container.getMappedPort(9093)
      • container.getConfig().getHostName():9092
      Parameters:
      listenerSupplier - a supplier that will provide a listener
      Returns:
      this KafkaContainer instance
    • brokerAdvertisedListener

      protected String brokerAdvertisedListener(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
      Deprecated.