use of io.confluent.kafka.schemaregistry.storage.serialization.SchemaRegistrySerializer in project schema-registry by confluentinc.
the class KafkaStoreTest method testKafkaStoreMessageHandlerSameIdDifferentDeletedSchema.
@Test
public void testKafkaStoreMessageHandlerSameIdDifferentDeletedSchema() 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, "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 SchemaRegistryKeysTest method testStoreKeyOrder.
private void testStoreKeyOrder(SchemaRegistryKey[] orderedKeys) throws StoreInitializationException {
int numKeys = orderedKeys.length;
InMemoryCache<SchemaRegistryKey, SchemaRegistryValue> store = new InMemoryCache<>(new SchemaRegistrySerializer());
store.init();
while (--numKeys >= 0) {
try {
store.put(orderedKeys[numKeys], toValue(orderedKeys[numKeys]));
} catch (StoreException e) {
fail("Error writing key " + orderedKeys[numKeys].toString() + " to the in memory store");
}
}
// test key order
try (CloseableIterator<SchemaRegistryKey> keys = store.getAllKeys()) {
SchemaRegistryKey[] retrievedKeyOrder = new SchemaRegistryKey[orderedKeys.length];
int keyIndex = 0;
while (keys.hasNext()) {
retrievedKeyOrder[keyIndex++] = keys.next();
}
assertArrayEquals(orderedKeys, retrievedKeyOrder);
} catch (StoreException e) {
fail();
}
}
Aggregations