Add SchemaRegistryContainer.java and testcontainers dependencies for integration tests
This commit is contained in:
parent
ce003eae93
commit
aebc0164de
3 changed files with 47 additions and 1 deletions
|
@ -119,7 +119,18 @@
|
|||
<artifactId>commons-pool2</artifactId>
|
||||
<version>${apache.commons.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>testcontainers</artifactId>
|
||||
<version>${test.containers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>kafka</artifactId>
|
||||
<version>${test.containers.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.provectus.kafka.ui;
|
||||
|
||||
import org.testcontainers.containers.GenericContainer;
|
||||
import org.testcontainers.containers.KafkaContainer;
|
||||
import org.testcontainers.containers.Network;
|
||||
|
||||
public class SchemaRegistryContainer extends GenericContainer<SchemaRegistryContainer> {
|
||||
private static final int SCHEMA_PORT = 8081;
|
||||
|
||||
public SchemaRegistryContainer() {
|
||||
this("5.2.1");
|
||||
}
|
||||
|
||||
public SchemaRegistryContainer(String version) {
|
||||
super("confluentinc/cp-schema-registry:" + version);
|
||||
withExposedPorts(8081);
|
||||
}
|
||||
|
||||
public SchemaRegistryContainer withKafka(KafkaContainer kafka) {
|
||||
return withKafka(kafka.getNetwork(), kafka.getNetworkAliases().get(0) + ":9092");
|
||||
}
|
||||
|
||||
public SchemaRegistryContainer withKafka(Network network, String bootstrapServers) {
|
||||
withNetwork(network);
|
||||
withEnv("SCHEMA_REGISTRY_HOST_NAME", "schema-registry");
|
||||
withEnv("SCHEMA_REGISTRY_LISTENERS", "http://0.0.0.0:" + SCHEMA_PORT);
|
||||
withEnv("SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS", "PLAINTEXT://" + bootstrapServers);
|
||||
return self();
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return "http://" + getContainerIpAddress() + ":" + getMappedPort(8081);
|
||||
}
|
||||
}
|
1
pom.xml
1
pom.xml
|
@ -31,6 +31,7 @@
|
|||
<avro.version>1.9.2</avro.version>
|
||||
<confluent.version>5.5.1</confluent.version>
|
||||
<apache.commons.version>2.2</apache.commons.version>
|
||||
<test.containers.version>1.15.1</test.containers.version>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
|
|
Loading…
Add table
Reference in a new issue