use of io.confluent.kafka.schemaregistry.SchemaProvider in project schema-registry by confluentinc.
the class JsonSchemaTest method testParseSchema.
@Test
public void testParseSchema() {
SchemaProvider jsonSchemaProvider = new JsonSchemaProvider();
ParsedSchema parsedSchema = jsonSchemaProvider.parseSchemaOrElseThrow(recordSchemaString, new ArrayList<>(), false);
Optional<ParsedSchema> parsedSchemaOptional = jsonSchemaProvider.parseSchema(recordSchemaString, new ArrayList<>(), false);
assertNotNull(parsedSchema);
assertTrue(parsedSchemaOptional.isPresent());
}
use of io.confluent.kafka.schemaregistry.SchemaProvider in project schema-registry by confluentinc.
the class SchemaRegistryMojo method client.
protected SchemaRegistryClient client() {
if (null == this.client) {
Map<String, String> config = new HashMap<>();
if (configs != null && !configs.isEmpty()) {
config.putAll(configs);
}
if (userInfoConfig != null) {
// Note that BASIC_AUTH_CREDENTIALS_SOURCE is not configurable as the plugin only supports
// a single schema registry URL, so there is no additional utility of the URL source.
config.put(SchemaRegistryClientConfig.BASIC_AUTH_CREDENTIALS_SOURCE, "USER_INFO");
config.put(SchemaRegistryClientConfig.USER_INFO_CONFIG, userInfoConfig);
}
List<SchemaProvider> providers = schemaProviders != null && !schemaProviders.isEmpty() ? schemaProviders() : MojoUtils.defaultSchemaProviders();
this.client = new CachedSchemaRegistryClient(this.schemaRegistryUrls, 1000, providers, config, httpHeaders);
}
return this.client;
}
use of io.confluent.kafka.schemaregistry.SchemaProvider in project schema-registry by confluentinc.
the class SchemaMessageReader method getSchemaRegistryClient.
private SchemaRegistryClient getSchemaRegistryClient(Properties props, String url) {
Map<String, Object> originals = getPropertiesMap(props);
final List<String> schemaRegistryUrls = Collections.singletonList(url);
final List<SchemaProvider> schemaProviders = Collections.singletonList(getProvider());
final String maybeMockScope = MockSchemaRegistry.validateAndMaybeGetMockScope(schemaRegistryUrls);
SchemaRegistryClient schemaRegistry;
if (maybeMockScope == null) {
schemaRegistry = new CachedSchemaRegistryClient(url, AbstractKafkaSchemaSerDeConfig.MAX_SCHEMAS_PER_SUBJECT_DEFAULT, schemaProviders, originals);
} else {
schemaRegistry = MockSchemaRegistry.getClientForScope(maybeMockScope, schemaProviders);
}
return schemaRegistry;
}
use of io.confluent.kafka.schemaregistry.SchemaProvider in project schema-registry by confluentinc.
the class AbstractKafkaSchemaSerDe method configureClientProperties.
protected void configureClientProperties(AbstractKafkaSchemaSerDeConfig config, SchemaProvider provider) {
List<String> urls = config.getSchemaRegistryUrls();
int maxSchemaObject = config.getMaxSchemasPerSubject();
Map<String, Object> originals = config.originalsWithPrefix("");
if (null == schemaRegistry) {
String mockScope = MockSchemaRegistry.validateAndMaybeGetMockScope(urls);
List<SchemaProvider> providers = Collections.singletonList(provider);
if (mockScope != null) {
schemaRegistry = MockSchemaRegistry.getClientForScope(mockScope, providers);
} else {
schemaRegistry = new CachedSchemaRegistryClient(urls, maxSchemaObject, providers, originals, config.requestHeaders());
}
}
contextNameStrategy = config.contextNameStrategy();
keySubjectNameStrategy = config.keySubjectNameStrategy();
valueSubjectNameStrategy = config.valueSubjectNameStrategy();
useSchemaReflection = config.useSchemaReflection();
}
use of io.confluent.kafka.schemaregistry.SchemaProvider in project schema-registry by confluentinc.
the class ProtobufSchemaTest method testParseSchema.
@Test
public void testParseSchema() {
SchemaProvider protobufSchemaProvider = new ProtobufSchemaProvider();
ParsedSchema parsedSchema = protobufSchemaProvider.parseSchemaOrElseThrow(recordSchemaString, new ArrayList<>(), false);
Optional<ParsedSchema> parsedSchemaOptional = protobufSchemaProvider.parseSchema(recordSchemaString, new ArrayList<>(), false);
assertNotNull(parsedSchema);
assertTrue(parsedSchemaOptional.isPresent());
}
Aggregations