Şu satırı dahil ederiz
import io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication;
Maven
Şu satırı dahil ederiz
<dependency> <groupId>io.confluent</groupId> <artifactId>kafka-schema-registry</artifactId> <version>6.2.2</version> <scope>test</scope> </dependency>
constructor
Şöyle yaparız
import io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig; import io.confluent.kafka.schemaregistry.rest.SchemaRegistryRestApplication; Properties properties = new Properties(); //properties.put("listeners", "http://0.0.0.0:0"); properties.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, ...);
properties.put(SchemaRegistryConfig.KAFKASTORE_TIMEOUT_CONFIG, "5000");
SchemaRegistryConfig config = new SchemaRegistryConfig(properties); SchemaRegistryRestApplication schemaRegistryApplication = new SchemaRegistryRestApplication(config); schemaRegistry = schemaRegistryApplication.createServer(); schemaRegistry.start();
Unit Test
schemaregistry-junit kullanılabilir
Örnek - JUnit 5
Şöyle yaparız
@RegisterExtension @Order(1) static final SharedKafkaTestResource kafka = new SharedKafkaTestResource().withBrokers(1); @RegisterExtension @Order(2) static final SharedSchemaRegistryTestResource schemaRegistry = new SharedSchemaRegistryTestResource() .withBootstrapServers(kafka::getKafkaConnectString);
Hiç yorum yok:
Yorum Gönder