Class MutableExtensionRegistry

    • Field Detail

      • logger

        private static final org.junit.platform.commons.logging.Logger logger
      • DEFAULT_STATELESS_EXTENSIONS

        private static final java.util.List<org.junit.jupiter.api.extension.Extension> DEFAULT_STATELESS_EXTENSIONS
      • registeredExtensionTypes

        private final java.util.Set<java.lang.Class<? extends org.junit.jupiter.api.extension.Extension>> registeredExtensionTypes
    • Constructor Detail

      • MutableExtensionRegistry

        private MutableExtensionRegistry()
      • MutableExtensionRegistry

        private MutableExtensionRegistry​(java.util.Set<java.lang.Class<? extends org.junit.jupiter.api.extension.Extension>> registeredExtensionTypes,
                                         java.util.List<MutableExtensionRegistry.Entry> registeredExtensions)
    • Method Detail

      • logExcludedExtensions

        private static void logExcludedExtensions​(java.util.List<java.lang.Class<? extends org.junit.jupiter.api.extension.Extension>> excludedExtensions)
      • createRegistryFrom

        public static MutableExtensionRegistry createRegistryFrom​(MutableExtensionRegistry parentRegistry,
                                                                  java.util.stream.Stream<java.lang.Class<? extends org.junit.jupiter.api.extension.Extension>> extensionTypes)
        Factory for creating and populating a new registry from a list of extension types and a parent registry.
        Parameters:
        parentRegistry - the parent registry
        extensionTypes - the types of extensions to be registered in the new registry
        Returns:
        a new ExtensionRegistry; never null
      • stream

        public <E extends org.junit.jupiter.api.extension.Extension> java.util.stream.Stream<E> stream​(java.lang.Class<E> extensionType)
        Description copied from interface: ExtensionRegistry
        Stream all Extensions of the specified type that are present in this registry or one of its ancestors.
        Specified by:
        stream in interface ExtensionRegistry
        Parameters:
        extensionType - the type of Extension to stream
        See Also:
        ExtensionRegistry.getExtensions(Class)
      • registerExtension

        public void registerExtension​(java.lang.Class<? extends org.junit.jupiter.api.extension.Extension> extensionType)
        Description copied from interface: ExtensionRegistrar
        Instantiate an extension of the given type using its default constructor and register it in the registry.

        A new Extension should not be registered if an extension of the given type already exists in the registry or a parent registry.

        Specified by:
        registerExtension in interface ExtensionRegistrar
        Parameters:
        extensionType - the type of extension to register
      • isAlreadyRegistered

        private boolean isAlreadyRegistered​(java.lang.Class<? extends org.junit.jupiter.api.extension.Extension> extensionType)
        Determine if the supplied type is already registered in this registry or in a parent registry.
      • registerExtension

        public void registerExtension​(org.junit.jupiter.api.extension.Extension extension,
                                      java.lang.Object source)
        Description copied from interface: ExtensionRegistrar
        Register the supplied Extension, without checking if an extension of that type has already been registered.

        Semantics for Source

        If an extension is registered declaratively via @ExtendWith, the source and the extension should be the same object. However, if an extension is registered programmatically via @RegisterExtension, the source object should be the Field that is annotated with @RegisterExtension. Similarly, if an extension is registered programmatically as a lambda expression or method reference, the source object should be the underlying Method that implements the extension API.

        Specified by:
        registerExtension in interface ExtensionRegistrar
        Parameters:
        extension - the extension to register; never null
        source - the source of the extension; never null
      • registerSyntheticExtension

        public void registerSyntheticExtension​(org.junit.jupiter.api.extension.Extension extension,
                                               java.lang.Object source)
        Description copied from interface: ExtensionRegistrar
        Register the supplied Extension as a synthetic extension, without checking if an extension of that type has already been registered.
        Specified by:
        registerSyntheticExtension in interface ExtensionRegistrar
        Parameters:
        extension - the extension to register; never null
        source - the source of the extension; never null
        See Also:
        ExtensionRegistrar.registerExtension(Extension, Object)
      • registerUninitializedExtension

        public void registerUninitializedExtension​(java.lang.Class<?> testClass,
                                                   java.lang.reflect.Field source,
                                                   java.util.function.Function<java.lang.Object,​? extends org.junit.jupiter.api.extension.Extension> initializer)
        Description copied from interface: ExtensionRegistrar
        Register an uninitialized extension for the supplied testClass to be initialized using the supplied initializer when an instance of the test class is created.

        Uninitialized extensions are typically registered for fields annotated with @RegisterExtension that 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:
        registerUninitializedExtension in interface ExtensionRegistrar
        Parameters:
        testClass - the test class for which the extension is registered; never null
        source - the source of the extension; never null
        initializer - the initializer function to be used to create the extension; never null
      • initializeExtensions

        public void initializeExtensions​(java.lang.Class<?> testClass,
                                         java.lang.Object testInstance)
        Description copied from interface: ExtensionRegistrar
        Initialize all registered extensions for the supplied testClass using the supplied testInstance.
        Specified by:
        initializeExtensions in interface ExtensionRegistrar
        Parameters:
        testClass - the test class for which the extensions are initialized; never null
        testInstance - the test instance to be used to initialize the extensions; never null
      • registerDefaultExtension

        private void registerDefaultExtension​(org.junit.jupiter.api.extension.Extension extension)
      • registerAutoDetectedExtension

        private void registerAutoDetectedExtension​(org.junit.jupiter.api.extension.Extension extension)
      • registerLocalExtension

        private void registerLocalExtension​(org.junit.jupiter.api.extension.Extension extension)
      • registerExtension

        private void registerExtension​(java.lang.String category,
                                       org.junit.jupiter.api.extension.Extension extension)
      • registerExtension

        private void registerExtension​(java.lang.String category,
                                       org.junit.jupiter.api.extension.Extension extension,
                                       java.lang.Object source)
      • buildSourceInfo

        private java.lang.String buildSourceInfo​(java.lang.Object source)