Class MockSchemaRegistry
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").
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()static voidDestroy the mocked registry corresponding to the scope.static SchemaRegistryClientgetClientForScope(String scope) Get a client for a mocked Schema Registry.static SchemaRegistryClientgetClientForScope(String scope, List<SchemaProvider> providers) Get a client for a mocked Schema Registry.static SchemaRegistryClientgetClientForScope(List<String> scopes, List<SchemaProvider> providers) Get a client for a mocked Schema Registry.validateAndMaybeGetMockScope(String baseUrls) static String
-
Method Details
-
getClientForScope
Get a client for a mocked Schema Registry. Thescoperepresents a particular registry, so operations on one scope will never affect another.- Parameters:
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.- Returns:
- A client for the specified scope.
-
getClientForScope
Get a client for a mocked Schema Registry. Thescoperepresents a particular registry, so operations on one scope will never affect another.- Parameters:
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.- Returns:
- A client for the specified scope.
-
getClientForScope
public static SchemaRegistryClient getClientForScope(List<String> scopes, List<SchemaProvider> providers) Get a client for a mocked Schema Registry. Thescoperepresents a particular registry, so operations on one scope will never affect another.- Parameters:
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.- Returns:
- A client for the specified scope.
-
dropScope
Destroy the mocked registry corresponding to the scope. Subsequent clients for the same scope will have a completely blank slate.- Parameters:
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.
-
clear
public static void clear() -
validateAndMaybeGetMockScope
-
validateAndMaybeGetMockScope
-