Class MutableExtensionRegistry
- All Implemented Interfaces:
ExtensionRegistrar,ExtensionRegistry
ExtensionRegistry.- Since:
- 5.5
-
Method Summary
Modifier and TypeMethodDescriptionstatic MutableExtensionRegistrycreateRegistryFrom(MutableExtensionRegistry parentRegistry, Stream<Class<? extends Extension>> extensionTypes) Factory for creating and populating a new registry from a list of extension types and a parent registry.static MutableExtensionRegistrycreateRegistryWithDefaultExtensions(JupiterConfiguration configuration) Factory for creating and populating a new root registry with the default extensions.voidinitializeExtensions(Class<?> testClass, Object testInstance) Initialize all registered extensions for the suppliedtestClassusing the suppliedtestInstance.voidregisterExtension(Class<? extends Extension> extensionType) Instantiate an extension of the given type using its default constructor and register it in the registry.voidregisterExtension(Extension extension, Object source) Register the suppliedExtension, without checking if an extension of that type has already been registered.voidregisterSyntheticExtension(Extension extension, Object source) Register the suppliedExtensionas a synthetic extension, without checking if an extension of that type has already been registered.voidregisterUninitializedExtension(Class<?> testClass, Field source, Function<Object, ? extends Extension> initializer) Register an uninitialized extension for the suppliedtestClassto be initialized using the suppliedinitializerwhen an instance of the test class is created.Stream allExtensionsof the specified type that are present in this registry or one of its ancestors.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.engine.extension.ExtensionRegistry
getExtensions
-
Method Details
-
createRegistryWithDefaultExtensions
public static MutableExtensionRegistry createRegistryWithDefaultExtensions(JupiterConfiguration configuration) Factory for creating and populating a new root registry with the default extensions.If the
Constants.EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAMEconfiguration parameter has been set totrue, extensions will be auto-detected using Java'sServiceLoadermechanism and automatically registered after the default extensions.If the "junit.jupiter.execution.timeout.threaddump.enabled" configuration parameter has been set to
true, thePreInterruptThreadDumpPrinterwill be registered.- Parameters:
configuration- configuration parameters used to retrieve the extension auto-detection flag; nevernull- Returns:
- a new
ExtensionRegistry; nevernull
-
createRegistryFrom
public static MutableExtensionRegistry createRegistryFrom(MutableExtensionRegistry parentRegistry, Stream<Class<? extends Extension>> extensionTypes) Factory for creating and populating a new registry from a list of extension types and a parent registry.- Parameters:
parentRegistry- the parent registryextensionTypes- the types of extensions to be registered in the new registry- Returns:
- a new
ExtensionRegistry; nevernull
-
stream
Description copied from interface:ExtensionRegistryStream allExtensionsof the specified type that are present in this registry or one of its ancestors.- Specified by:
streamin interfaceExtensionRegistry- Parameters:
extensionType- the type ofExtensionto stream- See Also:
-
registerExtension
Description copied from interface:ExtensionRegistrarInstantiate an extension of the given type using its default constructor and register it in the registry.A new
Extensionshould not be registered if an extension of the given type already exists in the registry or a parent registry.- Specified by:
registerExtensionin interfaceExtensionRegistrar- Parameters:
extensionType- the type of extension to register
-
registerExtension
Description copied from interface:ExtensionRegistrarRegister the suppliedExtension, without checking if an extension of that type has already been registered.Semantics for Source
If an extension is registered declaratively via
@ExtendWith, thesourceand theextensionshould be the same object. However, if an extension is registered programmatically via@RegisterExtension, thesourceobject should be theFieldthat is annotated with@RegisterExtension. Similarly, if an extension is registered programmatically as a lambda expression or method reference, thesourceobject should be the underlyingMethodthat implements the extension API.- Specified by:
registerExtensionin interfaceExtensionRegistrar- Parameters:
extension- the extension to register; nevernullsource- the source of the extension; nevernull
-
registerSyntheticExtension
Description copied from interface:ExtensionRegistrarRegister the suppliedExtensionas a synthetic extension, without checking if an extension of that type has already been registered.- Specified by:
registerSyntheticExtensionin interfaceExtensionRegistrar- Parameters:
extension- the extension to register; nevernullsource- the source of the extension; nevernull- See Also:
-
registerUninitializedExtension
public void registerUninitializedExtension(Class<?> testClass, Field source, Function<Object, ? extends Extension> initializer) Description copied from interface:ExtensionRegistrarRegister an uninitialized extension for the suppliedtestClassto be initialized using the suppliedinitializerwhen an instance of the test class is created.Uninitialized extensions are typically registered for fields annotated with
@RegisterExtensionthat cannot be initialized until an instance of the test class is created. Until they are initialized, such extensions are not available for use.- Specified by:
registerUninitializedExtensionin interfaceExtensionRegistrar- Parameters:
testClass- the test class for which the extension is registered; nevernullsource- the source of the extension; nevernullinitializer- the initializer function to be used to create the extension; nevernull
-
initializeExtensions
Description copied from interface:ExtensionRegistrarInitialize all registered extensions for the suppliedtestClassusing the suppliedtestInstance.- Specified by:
initializeExtensionsin interfaceExtensionRegistrar- Parameters:
testClass- the test class for which the extensions are initialized; nevernulltestInstance- the test instance to be used to initialize the extensions; nevernull
-