Search in sources :

Example 1 with SchemaRegistrySerializer

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);
}
Also used : SchemaRegistryConfig(io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig) SchemaRegistrySerializer(io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with SchemaRegistrySerializer

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));
}
Also used : SchemaRegistryConfig(io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig) SchemaRegistrySerializer(io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with SchemaRegistrySerializer

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);
}
Also used : SchemaRegistryConfig(io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig) SchemaRegistrySerializer(io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer) Properties(java.util.Properties) IncrementalIdGenerator(io.confluent.kafka.schemaregistry.id.IncrementalIdGenerator) Test(org.junit.Test)

Example 4 with SchemaRegistrySerializer

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));
}
Also used : SchemaRegistryConfig(io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig) SchemaRegistrySerializer(io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with SchemaRegistrySerializer

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());
}
Also used : SchemaRegistryConfig(io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig) SchemaRegistrySerializer(io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

SchemaRegistrySerializer (io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer)12 SchemaRegistryConfig (io.confluent.kafka.schemaregistry.rest.SchemaRegistryConfig)10 Properties (java.util.Properties)10 Test (org.junit.Test)10 IncrementalIdGenerator (io.confluent.kafka.schemaregistry.id.IncrementalIdGenerator)2 SchemaRegistryException (io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryException)1 KafkaSchemaRegistry (io.confluent.kafka.schemaregistry.storage.KafkaSchemaRegistry)1 StoreException (io.confluent.kafka.schemaregistry.storage.exceptions.StoreException)1