use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testKafkaStoreMessageHandlerSameIdSameDeletedSchema.
@Test
public void testKafkaStoreMessageHandlerSameIdSameDeletedSchema() 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("subject", 1), new SchemaValue("subject", 1, id, "schemaString", true));
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 testGetAlwaysTrueHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsNone.
@Test
public void testGetAlwaysTrueHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsNone() throws Exception {
Properties props = new Properties();
props.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, ClusterTestHarness.KAFKASTORE_TOPIC);
props.put(SchemaRegistryConfig.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, "none");
SchemaRegistryConfig config = new SchemaRegistryConfig(props);
KafkaSchemaRegistry schemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
assertTrue(schemaRegistry.getHostnameVerifier().verify("", null));
}
use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testKafkaStoreMessageHandlerDeleteSubjectKeyNullValue.
// Test no NPE happens when handling DeleteSubjectKey with null value
@Test
public void testKafkaStoreMessageHandlerDeleteSubjectKeyNullValue() 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 DeleteSubjectKey("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 testGetAlwaysTrueHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsEmptyString.
@Test
public void testGetAlwaysTrueHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsEmptyString() throws Exception {
Properties props = new Properties();
props.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, ClusterTestHarness.KAFKASTORE_TOPIC);
props.put(SchemaRegistryConfig.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, "");
SchemaRegistryConfig config = new SchemaRegistryConfig(props);
KafkaSchemaRegistry schemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
assertTrue(schemaRegistry.getHostnameVerifier().verify("", null));
}
use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testGetNullHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsHttps.
@Test
public void testGetNullHostnameVerifierWhenSslEndpointIdentificationAlgorithmIsHttps() throws Exception {
Properties props = new Properties();
props.put(SchemaRegistryConfig.KAFKASTORE_BOOTSTRAP_SERVERS_CONFIG, bootstrapServers);
props.put(SchemaRegistryConfig.KAFKASTORE_TOPIC_CONFIG, ClusterTestHarness.KAFKASTORE_TOPIC);
props.put(SchemaRegistryConfig.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG, "https");
SchemaRegistryConfig config = new SchemaRegistryConfig(props);
KafkaSchemaRegistry schemaRegistry = new KafkaSchemaRegistry(config, new SchemaRegistrySerializer());
assertNull(schemaRegistry.getHostnameVerifier());
}
Aggregations