Class CustomJsonUnitMatcherLoader


  • public final class CustomJsonUnitMatcherLoader
    extends Object
    Loads the CustomJsonUnitMatcherProvider class named by mockserver.customJsonUnitMatchersClass and exposes the matchers it produces.

    The provider class is instantiated once via its public no-arg constructor and its matcher map is cached for the JVM lifetime keyed on the class name, so changing the configuration property at runtime (e.g. between tests) picks up the new provider on next access.

    If the property is blank, the named class cannot be loaded, the class does not implement CustomJsonUnitMatcherProvider, or any exception is thrown during instantiation, an empty map is returned and a WARN log entry is written - matching is never failed because of a misconfigured provider.

    • Method Detail

      • load

        public static Map<String,​org.hamcrest.Matcher<?>> load()
        Returns the named matchers contributed by the configured provider, or an empty map if no provider is configured or the provider cannot be loaded.
      • reset

        public static void reset()
        Clears the cached provider so the next call to load() re-reads the configuration property and re-instantiates the provider. Intended for tests that change the property between cases.