public final class MockSchemaRegistry extends Object
Logically independent "instances" of mocked Schema Registry are created or retrieved
via named scopes getClientForScope(String).
Each named scope is an independent registry.
Each named-scope registry is statically defined and visible to the entire JVM.
Scopes can be cleaned up when no longer needed via dropScope(String).
Reusing a scope name after cleanup results in a completely new mocked Schema Registry instance.
This registry can be used to manage scoped clients directly, but scopes can also be registered
and used as schema.registry.url with the special pseudo-protocol 'mock://'
in serde configurations, so that testing code doesn't have to run an actual instance of
Schema Registry listening on a local port. For example,
schema.registry.url: 'mock://my-scope-name' corresponds to
MockSchemaRegistry.getClientForScope("my-scope-name").
| Modifier and Type | Method and Description |
|---|---|
static void |
clear() |
static void |
dropScope(String scope)
Destroy the mocked registry corresponding to the scope.
|
static SchemaRegistryClient |
getClientForScope(List<String> scopes,
List<SchemaProvider> providers)
Get a client for a mocked Schema Registry.
|
static SchemaRegistryClient |
getClientForScope(String scope)
Get a client for a mocked Schema Registry.
|
static SchemaRegistryClient |
getClientForScope(String scope,
List<SchemaProvider> providers)
Get a client for a mocked Schema Registry.
|
static String |
validateAndMaybeGetMockScope(List<String> urls) |
static List<String> |
validateAndMaybeGetMockScope(String baseUrls) |
public static SchemaRegistryClient getClientForScope(String scope)
scope represents a particular registry,
so operations on one scope will never affect another.scope - Identifies a logically independent Schema Registry instance. It's similar to a
schema registry URL, in that two different Schema Registry deployments have two
different URLs, except that these registries are only mocked, so they have no
actual URL.public static SchemaRegistryClient getClientForScope(String scope, List<SchemaProvider> providers)
scope represents a particular registry,
so operations on one scope will never affect another.scope - Identifies a logically independent Schema Registry instance. It's similar to a
schema registry URL, in that two different Schema Registry deployments have two
different URLs, except that these registries are only mocked, so they have no
actual URL.providers - A list of schema providers.public static SchemaRegistryClient getClientForScope(List<String> scopes, List<SchemaProvider> providers)
scope represents a particular registry,
so operations on one scope will never affect another.scopes - Identifies a logically independent Schema Registry instance. It's similar to a
List of schema registry URLs, in that two different Schema Registry deployments
have two different URLs, except that these registries are only mocked, so they
have no actual URL.providers - A list of schema providers.public static void dropScope(String scope)
scope - Identifies a logically independent Schema Registry instance. It's similar to a
schema registry URL, in that two different Schema Registry deployments have two
different URLs, except that these registries are only mocked, so they have no
actual URL.public static void clear()
Copyright © 2025 Confluent, Inc.. All rights reserved.