Top Description Inners Fields Constructors Methods
org.junit.jupiter.engine.extension

public Class MutableExtensionRegistry

extends Object
implements ExtensionRegistry, ExtensionRegistrar
Class Inheritance
All Implemented Interfaces
org.junit.jupiter.engine.extension.ExtensionRegistrar, org.junit.jupiter.engine.extension.ExtensionRegistry
Annotations
@API
status:INTERNAL
since:5.5
Static Imports
java.util.Collections.emptyList, .Collections.emptySet, org.apiguardian.api.API.Status.INTERNAL

Default, mutable implementation of ExtensionRegistry.
Since
5.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final List<Extension>
private final Map<Class<?>, MutableExtensionRegistry.LateInitExtensions>
private static final Logger
private final List<MutableExtensionRegistry.Entry>
private final Set<Class<? extends Extension>>

Constructor Summary

AccessConstructor and Description
private
private
private
MutableExtensionRegistry(Set<Class<? extends Extension>> registeredExtensionTypes, List<MutableExtensionRegistry.Entry> registeredExtensions)

Method Summary

Modifier and TypeMethod and Description
private String
public static MutableExtensionRegistry

Returns:

a new ExtensionRegistry; never null
createRegistryFrom
(MutableExtensionRegistry
the parent registry
parentRegistry
,
Stream<Class<? extends Extension>>
the types of extensions to be registered in the new registry
extensionTypes
)

Factory for creating and populating a new registry from a list of extension types and a parent registry.

public static MutableExtensionRegistry

Returns:

a new ExtensionRegistry; never null
createRegistryWithDefaultExtensions
(JupiterConfiguration
configuration parameters used to retrieve the extension auto-detection flag; never null
configuration
)

Factory for creating and populating a new root registry with the default extensions.

private MutableExtensionRegistry.LateInitExtensions
public void
initializeExtensions(Class<?> testClass, Object testInstance)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.initializeExtensions.

Initialize all registered extensions for the supplied testClass using the supplied testInstance.

private boolean
isAlreadyRegistered(Class<? extends Extension> extensionType)

Determine if the supplied type is already registered in this registry or in a parent registry.

private static void
logExcludedExtensions(List<Class<? extends Extension>> excludedExtensions)

private void
private static void
private void
public void
registerExtension(Class<? extends Extension> extensionType)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerExtension.

Instantiate an extension of the given type using its default constructor and register it in the registry.

public void
registerExtension(Extension extension, Object source)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerExtension.

Register the supplied Extension, without checking if an extension of that type has already been registered.

private void
registerExtension(String category, Extension extension)

private void
registerExtension(String category, Extension extension, @Nullable Object source)

private void
public void
registerSyntheticExtension(Extension extension, Object source)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerSyntheticExtension.

Register the supplied Extension as a synthetic extension, without checking if an extension of that type has already been registered.

public void
registerUninitializedExtension(Class<?> testClass, Field source, Function<Object, ? extends Extension> initializer)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerUninitializedExtension.

Register an uninitialized extension for the supplied testClass to be initialized using the supplied initializer when an instance of the test class is created.

public <E extends Extension> Stream<E>
stream(Class<E> extensionType)

Implements org.junit.jupiter.engine.extension.ExtensionRegistry.stream.

Stream all Extensions of the specified type that are present in this registry or one of its ancestors.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_STATELESS_EXTENSIONSback to summary
private static final List<Extension> DEFAULT_STATELESS_EXTENSIONS
lateInitExtensionsback to summary
private final Map<Class<?>, MutableExtensionRegistry.LateInitExtensions> lateInitExtensions
loggerback to summary
private static final Logger logger
registeredExtensionsback to summary
private final List<MutableExtensionRegistry.Entry> registeredExtensions
registeredExtensionTypesback to summary
private final Set<Class<? extends Extension>> registeredExtensionTypes

Constructor Detail

MutableExtensionRegistryback to summary
private MutableExtensionRegistry()
MutableExtensionRegistryback to summary
private MutableExtensionRegistry(MutableExtensionRegistry parent)
MutableExtensionRegistryback to summary
private MutableExtensionRegistry(Set<Class<? extends Extension>> registeredExtensionTypes, List<MutableExtensionRegistry.Entry> registeredExtensions)

Method Detail

buildSourceInfoback to summary
private String buildSourceInfo(@Nullable Object source)
createRegistryFromback to summary
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:MutableExtensionRegistry

the parent registry

extensionTypes:Stream<Class<? extends Extension>>

the types of extensions to be registered in the new registry

Returns:MutableExtensionRegistry

a new ExtensionRegistry; never null

createRegistryWithDefaultExtensionsback to summary
public static MutableExtensionRegistry createRegistryWithDefaultExtensions(JupiterConfiguration configuration)

Factory for creating and populating a new root registry with the default extensions.

If the org.junit.jupiter.engine.Constants#EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME configuration parameter has been set to true, extensions will be auto-detected using Java's ServiceLoader mechanism and automatically registered after the default extensions.

If the junit.jupiter.execution.timeout.threaddump.enabled configuration parameter has been set to true, the PreInterruptThreadDumpPrinter will be registered.

Parameters
configuration:JupiterConfiguration

configuration parameters used to retrieve the extension auto-detection flag; never null

Returns:MutableExtensionRegistry

a new ExtensionRegistry; never null

getLateInitExtensionsback to summary
private MutableExtensionRegistry.LateInitExtensions getLateInitExtensions(Class<?> testClass)
initializeExtensionsback to summary
public void initializeExtensions(Class<?> testClass, Object testInstance)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.initializeExtensions.

Doc from org.junit.jupiter.engine.extension.ExtensionRegistrar.initializeExtensions.

Initialize all registered extensions for the supplied testClass using the supplied testInstance.

Annotations
@Override
isAlreadyRegisteredback to summary
private boolean isAlreadyRegistered(Class<? extends Extension> extensionType)

Determine if the supplied type is already registered in this registry or in a parent registry.

logExcludedExtensionsback to summary
private static void logExcludedExtensions(List<Class<? extends Extension>> excludedExtensions)
registerAutoDetectedExtensionback to summary
private void registerAutoDetectedExtension(Extension extension)
registerAutoDetectedExtensionsback to summary
private static void registerAutoDetectedExtensions(MutableExtensionRegistry extensionRegistry, JupiterConfiguration configuration)
registerDefaultExtensionback to summary
private void registerDefaultExtension(Extension extension)
registerExtensionback to summary
public void registerExtension(Class<? extends Extension> extensionType)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerExtension.

Doc from org.junit.jupiter.engine.extension.ExtensionRegistrar.registerExtension.

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.

Annotations
@Override
registerExtensionback to summary
public void registerExtension(Extension extension, Object source)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerExtension.

Doc from org.junit.jupiter.engine.extension.ExtensionRegistrar.registerExtension.

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 java.lang.reflect.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 java.lang.reflect.Method that implements the extension API.

Annotations
@Override
registerExtensionback to summary
private void registerExtension(String category, Extension extension)
registerExtensionback to summary
private void registerExtension(String category, Extension extension, @Nullable Object source)
registerLocalExtensionback to summary
private void registerLocalExtension(Extension extension)
registerSyntheticExtensionback to summary
public void registerSyntheticExtension(Extension extension, Object source)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerSyntheticExtension.

Doc from org.junit.jupiter.engine.extension.ExtensionRegistrar.registerSyntheticExtension.

Register the supplied Extension as a synthetic extension, without checking if an extension of that type has already been registered.

Annotations
@Override
registerUninitializedExtensionback to summary
public void registerUninitializedExtension(Class<?> testClass, Field source, Function<Object, ? extends Extension> initializer)

Implements org.junit.jupiter.engine.extension.ExtensionRegistrar.registerUninitializedExtension.

Doc from org.junit.jupiter.engine.extension.ExtensionRegistrar.registerUninitializedExtension.

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.

Annotations
@Override
streamback to summary
public <E extends Extension> Stream<E> stream(Class<E> extensionType)

Implements org.junit.jupiter.engine.extension.ExtensionRegistry.stream.

Doc from org.junit.jupiter.engine.extension.ExtensionRegistry.stream.

Stream all Extensions of the specified type that are present in this registry or one of its ancestors.

Annotations
@Override
org.junit.jupiter.engine.extension back to summary

private Interface MutableExtensionRegistry.Entry

Known Direct Implementers
org.junit.jupiter.engine.extension.MutableExtensionRegistry.LateInitEntry

Method Summary

Modifier and TypeMethod and Description
public Optional<Extension>
public static MutableExtensionRegistry.Entry
of(Extension extension)

Method Detail

getExtensionback to summary
public Optional<Extension> getExtension()
ofback to summary
public static MutableExtensionRegistry.Entry of(Extension extension)
org.junit.jupiter.engine.extension back to summary

private Class MutableExtensionRegistry.LateInitEntry

extends Object
implements Entry
Class Inheritance
  • java.lang.Object
  • org.junit.jupiter.engine.extension.MutableExtensionRegistry.LateInitEntry
All Implemented Interfaces
org.junit.jupiter.engine.extension.MutableExtensionRegistry.Entry

Field Summary

Modifier and TypeField and Description
private Optional<Extension>
private final Function<Object, ? extends Extension>
private final Class<?>

Constructor Summary

AccessConstructor and Description
pack-priv
LateInitEntry(Class<?> testClass, Function<Object, ? extends Extension> initializer)

Method Summary

Modifier and TypeMethod and Description
pack-priv MutableExtensionRegistry.LateInitEntry
copy()

public Optional<Extension>
private Class<?>
pack-priv void
initialize(Object testInstance)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

extensionback to summary
private Optional<Extension> extension
Annotations
@SuppressWarnings:OptionalUsedAsFieldOrParameterType
initializerback to summary
private final Function<Object, ? extends Extension> initializer
testClassback to summary
private final Class<?> testClass

Constructor Detail

LateInitEntryback to summary
pack-priv LateInitEntry(Class<?> testClass, Function<Object, ? extends Extension> initializer)

Method Detail

copyback to summary
pack-priv MutableExtensionRegistry.LateInitEntry copy()
getExtensionback to summary
public Optional<Extension> getExtension()

Implements org.junit.jupiter.engine.extension.MutableExtensionRegistry.Entry.getExtension.

Annotations
@Override
getTestClassback to summary
private Class<?> getTestClass()
initializeback to summary
pack-priv void initialize(Object testInstance)
org.junit.jupiter.engine.extension back to summary

private Class MutableExtensionRegistry.LateInitExtensions

extends Object
Class Inheritance
  • java.lang.Object
  • org.junit.jupiter.engine.extension.MutableExtensionRegistry.LateInitExtensions

Field Summary

Modifier and TypeField and Description
private final List<MutableExtensionRegistry.LateInitEntry>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv MutableExtensionRegistry.LateInitEntry
pack-priv void
initialize(Object testInstance)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private final List<MutableExtensionRegistry.LateInitEntry> entries

Constructor Detail

LateInitExtensionsback to summary
private LateInitExtensions()

Method Detail

addback to summary
pack-priv MutableExtensionRegistry.LateInitEntry add(MutableExtensionRegistry.LateInitEntry entry)
initializeback to summary
pack-priv void initialize(Object testInstance)