Class MockDekRegistryClientFactory

java.lang.Object
io.confluent.dekregistry.client.MockDekRegistryClientFactory

public final class MockDekRegistryClientFactory extends Object
A repository for mocked DEK Registry clients, to aid in testing.

Logically independent "instances" of mocked DEK Registry are created or retrieved via named scopes getClientForScope(String, Map). 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 repository 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 MockDekRegistryClientFactory.getClientForScope("my-scope-name", configs).

  • Method Details

    • getClientForScope

      public static DekRegistryClient getClientForScope(String scope, Map<String,?> configs)
      Get a client for a mocked Schema Registry. The scope represents 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

      public static DekRegistryClient getClientForScope(String scope, Map<String,?> configs, List<SchemaProvider> providers)
    • dropScope

      public static void dropScope(String scope)
      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

      public static String validateAndMaybeGetMockScope(List<String> urls)