Package org.mockserver.matchers
Class CustomJsonUnitMatcherLoader
java.lang.Object
org.mockserver.matchers.CustomJsonUnitMatcherLoader
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 Summary
Modifier and TypeMethodDescriptionload()Returns the named matchers contributed by the configured provider, or an empty map if no provider is configured or the provider cannot be loaded.load(Configuration configuration) Asload()but preferring thecustomJsonUnitMatchersClassvalue carried on the suppliedConfigurationinstance, falling back to the staticConfigurationPropertiesstore when it isnull.static voidreset()Clears the cached provider so the next call toload()re-reads the configuration property and re-instantiates the provider.
-
Method Details
-
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. -
load
Asload()but preferring thecustomJsonUnitMatchersClassvalue carried on the suppliedConfigurationinstance, falling back to the staticConfigurationPropertiesstore when it isnull. This is what makes a provider class configured overPUT /mockserver/configurationactually load.- Parameters:
configuration- the live server configuration, ornullto read the static store
-
reset
public static void reset()Clears the cached provider so the next call toload()re-reads the configuration property and re-instantiates the provider. Intended for tests that change the property between cases.
-