Maven
Şu satırı dahil ederiz
<dependency> <groupId>org.testcontainers</groupId> <artifactId>redpand</artifactId> <version>1.17.6</version> <scope>test</scope> </dependency>
constructor
Örnek
Şöyle yaparız
RedpandaContainer redpanda = new RedpandaContainer("docker.redpanda.com/redpandadata/redpanda:latest");
getBootstrapServers metodu
Örnek
Şöyle yaparız
import org.testcontainers.redpanda.RedpandaContainer; import org.testcontainers.utility.DockerImageName; import org.apache.kafka.clients.admin.Admin; DockerImageName imageName = parse("docker.redpanda.com/redpandadata/redpanda:v22.3.20"); redpandaContainer = new RedpandaContainer(imageName) .withLogConsumer(new Slf4jLogConsumer(LOGGER)); redpandaContainer.start(); String brokerConnectionString = redpandaContainer.getBootstrapServers(); Properties props = new Properties(); props.setProperty("bootstrap.servers", brokerConnectionString); Admin admin = Admin.create(props);
No comments:
Post a Comment