use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class SchemaRegistryRestApplication method initSchemaRegistry.
protected KafkaSchemaRegistry initSchemaRegistry(SchemaRegistryConfig config) {
KafkaSchemaRegistry kafkaSchemaRegistry = null;
try {
kafkaSchemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
kafkaSchemaRegistry.init();
} catch (SchemaRegistryException e) {
log.error("Error starting the schema registry", e);
onShutdown();
System.exit(1);
}
return kafkaSchemaRegistry;
}
use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testKafkaStoreMessageHandlerSameIdSameSchema.
@Test
public void testKafkaStoreMessageHandlerSameIdSameSchema() throws Exception {
Properties props = new Properties();
props.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, ClusterTestHarness.KAFKASTORE_TOPIC);
SchemaRegistryConfig config = new SchemaRegistryConfig(props);
KafkaSchemaRegistry schemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
KafkaStore<SchemaRegistryKey, SchemaRegistryValue> kafkaStore = schemaRegistry.kafkaStore;
kafkaStore.init();
int id = 100;
kafkaStore.put(new SchemaKey("subject", 1), new SchemaValue("subject", 1, id, "schemaString", false));
kafkaStore.put(new SchemaKey("subject2", 1), new SchemaValue("subject2", 1, id, "schemaString", false));
int size = 0;
try (CloseableIterator<SchemaRegistryKey> keys = kafkaStore.getAllKeys()) {
for (Iterator<SchemaRegistryKey> iter = keys; iter.hasNext(); ) {
size++;
iter.next();
}
}
assertEquals(2, size);
}
use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testKafkaStoreMessageHandlerClearSubjectKeyNullValue.
// Test no NPE happens when handling ClearSubjectKey with null value
@Test
public void testKafkaStoreMessageHandlerClearSubjectKeyNullValue() throws Exception {
Properties props = new Properties();
props.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, ClusterTestHarness.KAFKASTORE_TOPIC);
SchemaRegistryConfig config = new SchemaRegistryConfig(props);
KafkaSchemaRegistry schemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
InMemoryCache<SchemaRegistryKey, SchemaRegistryValue> store = new InMemoryCache<>(new SchemaRegistrySerializer());
store.init();
KafkaStoreMessageHandler storeMessageHandler = new KafkaStoreMessageHandler(schemaRegistry, store, new IncrementalIdGenerator(schemaRegistry));
storeMessageHandler.handleUpdate(new ClearSubjectKey("test"), null, null, null, 0L, 0L);
}
use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testKafkaStoreMessageHandlerSameIdDifferentSchema.
@Test
public void testKafkaStoreMessageHandlerSameIdDifferentSchema() throws Exception {
Properties props = new Properties();
props.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, ClusterTestHarness.KAFKASTORE_TOPIC);
SchemaRegistryConfig config = new SchemaRegistryConfig(props);
KafkaSchemaRegistry schemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
KafkaStore<SchemaRegistryKey, SchemaRegistryValue> kafkaStore = schemaRegistry.kafkaStore;
kafkaStore.init();
int id = 100;
kafkaStore.put(new SchemaKey("subject", 1), new SchemaValue("subject", 1, id, "schemaString", false));
kafkaStore.put(new SchemaKey("subject2", 1), new SchemaValue("subject2", 1, id, "schemaString2", false));
int size = 0;
try (CloseableIterator<SchemaRegistryKey> keys = kafkaStore.getAllKeys()) {
for (Iterator<SchemaRegistryKey> iter = keys; iter.hasNext(); ) {
size++;
iter.next();
}
}
assertEquals(1, size);
}
use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testGetAlwaysTrueHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsNotSet.
@Test
public void testGetAlwaysTrueHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsNotSet() throws Exception {
Properties props = new Properties();
props.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, ClusterTestHarness.KAFKASTORE_TOPIC);
SchemaRegistryConfig config = new SchemaRegistryConfig(props);
KafkaSchemaRegistry schemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
assertTrue(schemaRegistry.getHostnameVerifier().verify("", null));
}
Aggregations