-
Notifications
You must be signed in to change notification settings - Fork 16
/
SchemaRegistryContainer.java
50 lines (42 loc) · 1.58 KB
/
SchemaRegistryContainer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package io.confluent.testcontainers;
import static org.testcontainers.utility.DockerImageName.parse;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
/**
* This container wraps Confluent Schema Registry
* To learn more about Schema Registry https://docs.confluent.io/current/schema-registry/schema_registry_tutorial.html
*
* @since 0.1
*/
public class SchemaRegistryContainer extends GenericContainer<SchemaRegistryContainer> {
public SchemaRegistryContainer(String version) {
super(parse("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:8081");
withEnv("SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS", "PLAINTEXT://" + bootstrapServers);
return self();
}
/**
* Not very good name for this method ;)
*
* @deprecated use {@link #getSchemaRegistryUrl()}} instead.
*/
@Deprecated
public String getTarget() {
return "http://" + getContainerIpAddress() + ":" + getMappedPort(8081);
}
/**
* @return Schema Registry URL
*/
public String getSchemaRegistryUrl() {
return "http://" + getContainerIpAddress() + ":" + getMappedPort(8081);
}
}