Top Fields Constructors Methods
org.junit.jupiter.engine.descriptor

pack-priv abstract Class AbstractExtensionContext<T extends TestDescriptor>

extends Object
implements ExtensionContextInternal, AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable, org.junit.jupiter.engine.extension.ExtensionContextInternal, org.junit.jupiter.api.extension.ExtensionContext
Known Direct Subclasses
org.junit.jupiter.engine.descriptor.ClassExtensionContext, org.junit.jupiter.engine.descriptor.ClassTemplateInvocationExtensionContext, org.junit.jupiter.engine.descriptor.DynamicExtensionContext, org.junit.jupiter.engine.descriptor.JupiterEngineExtensionContext, org.junit.jupiter.engine.descriptor.MethodExtensionContext, org.junit.jupiter.engine.descriptor.TestTemplateExtensionContext
Static Imports
java.util.stream.Collectors.collectingAndThen, .Collectors.toCollection

Since
5.0

Field Summary

Modifier and TypeField and Description
private static final ExtensionContext.Namespace
private final JupiterConfiguration
private final EngineExecutionListener
private final ExecutableInvoker
private final ExtensionRegistry
private final LauncherStoreFacade
private static final Logger
private final @Nullable ExtensionContext
private final Set<String>
private final T
private final NamespacedHierarchicalStore<Namespace>

Constructor Summary

AccessConstructor and Description
pack-priv
AbstractExtensionContext(@Nullable ExtensionContext parent, EngineExecutionListener engineExecutionListener, T testDescriptor, JupiterConfiguration configuration, ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

private <N> NamespacedHierarchicalStore.CloseAction<N>
private Path
public Optional<String>
getConfigurationParameter(String key)

Implements org.junit.jupiter.api.extension.ExtensionContext.getConfigurationParameter.

Get the configuration parameter stored under the specified key.

public <V> Optional<V>
getConfigurationParameter(String key, Function<? super String, ? extends @Nullable V> transformer)

Implements org.junit.jupiter.api.extension.ExtensionContext.getConfigurationParameter.

Get and transform the configuration parameter stored under the specified key using the specified transformer.

public String
getDisplayName()

Implements org.junit.jupiter.api.extension.ExtensionContext.getDisplayName.

Get the display name for the current test or container.

public ExecutableInvoker
getExecutableInvoker()

Implements org.junit.jupiter.api.extension.ExtensionContext.getExecutableInvoker.

Get an ExecutableInvoker to invoke methods and constructors with support for dynamic resolution of parameters.

public ExecutionMode
getExecutionMode()

Implements org.junit.jupiter.api.extension.ExtensionContext.getExecutionMode.

Get the ExecutionMode associated with the current test or container.

public <E extends Extension> List<E>
getExtensions(Class<E> extensionType)

Implements org.junit.jupiter.engine.extension.ExtensionContextInternal.getExtensions.

Returns a list of registered extension at this context of the passed extensionType.

public Optional<ExtensionContext>
getParent()

Implements org.junit.jupiter.api.extension.ExtensionContext.getParent.

Get the parent extension context, if available.

private NamespacedHierarchicalStore<Namespace>
protected abstract Node.ExecutionMode
public ExtensionContext
getRoot()

Implements org.junit.jupiter.api.extension.ExtensionContext.getRoot.

Get the root ExtensionContext.

public ExtensionContext.Store
public ExtensionContext.Store
getStore(ExtensionContext.StoreScope scope, ExtensionContext.Namespace namespace)

Implements org.junit.jupiter.api.extension.ExtensionContext.getStore.

Returns the store for supplied scope and namespace.

public Set<String>
getTags()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTags.

Get the set of all tags for the current test or container.

protected T
public String
getUniqueId()

Implements org.junit.jupiter.api.extension.ExtensionContext.getUniqueId.

Get the unique ID of the current test or container.

public void
publishDirectory(String name, ThrowingConsumer<Path> action)

Implements org.junit.jupiter.api.extension.ExtensionContext.publishDirectory.

Publish a directory with the supplied name written by the supplied action and attach it to the current test or container.

public void
publishFile(String name, MediaType mediaType, ThrowingConsumer<Path> action)

Implements org.junit.jupiter.api.extension.ExtensionContext.publishFile.

Publish a file with the supplied name written by the supplied action and attach it to the current test or container.

private void
publishFileEntry(String name, ThrowingConsumer<Path> action, Function<Path, FileEntry> fileEntryCreator)

public void
publishReportEntry(Map<String, String> values)

Implements org.junit.jupiter.api.extension.ExtensionContext.publishReportEntry.

Publish a map of key-value pairs to be consumed by an org.junit.platform.engine.EngineExecutionListener in order to supply additional information to the reporting infrastructure.

private ExecutionMode
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLOSEABLE_RESOURCE_LOGGING_NAMESPACEback to summary
private static final ExtensionContext.Namespace CLOSEABLE_RESOURCE_LOGGING_NAMESPACE
configurationback to summary
private final JupiterConfiguration configuration
engineExecutionListenerback to summary
private final EngineExecutionListener engineExecutionListener
executableInvokerback to summary
private final ExecutableInvoker executableInvoker
extensionRegistryback to summary
private final ExtensionRegistry extensionRegistry
launcherStoreFacadeback to summary
private final LauncherStoreFacade launcherStoreFacade
LOGGERback to summary
private static final Logger LOGGER
parentback to summary
private final @Nullable ExtensionContext parent
tagsback to summary
private final Set<String> tags
testDescriptorback to summary
private final T testDescriptor
valuesStoreback to summary
private final NamespacedHierarchicalStore<Namespace> valuesStore

Constructor Detail

AbstractExtensionContextback to summary
pack-priv AbstractExtensionContext(@Nullable ExtensionContext parent, EngineExecutionListener engineExecutionListener, T testDescriptor, JupiterConfiguration configuration, ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade)

Method Detail

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
createCloseActionback to summary
private <N> NamespacedHierarchicalStore.CloseAction<N> createCloseAction()
Annotations
@SuppressWarnings:deprecation
createOutputDirectoryback to summary
private Path createOutputDirectory()
getConfigurationParameterback to summary
public Optional<String> getConfigurationParameter(String key)

Implements org.junit.jupiter.api.extension.ExtensionContext.getConfigurationParameter.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getConfigurationParameter.

Get the configuration parameter stored under the specified key.

If no such key is present in the ConfigurationParameters for the JUnit Platform, an attempt will be made to look up the value as a JVM system property. If no such system property exists, an attempt will be made to look up the value in the JUnit Platform properties file.

Annotations
@Override
getConfigurationParameterback to summary
public <V> Optional<V> getConfigurationParameter(String key, Function<? super String, ? extends @Nullable V> transformer)

Implements org.junit.jupiter.api.extension.ExtensionContext.getConfigurationParameter.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getConfigurationParameter.

Get and transform the configuration parameter stored under the specified key using the specified transformer.

If no such key is present in the ConfigurationParameters for the JUnit Platform, an attempt will be made to look up the value as a JVM system property. If no such system property exists, an attempt will be made to look up the value in the JUnit Platform properties file.

In case the transformer throws an exception, it will be wrapped in a org.junit.platform.commons.JUnitException with a helpful message.

Annotations
@Override
getDisplayNameback to summary
public String getDisplayName()

Implements org.junit.jupiter.api.extension.ExtensionContext.getDisplayName.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getDisplayName.

Get the display name for the current test or container.

The display name is either a default name or a custom name configured via @DisplayName.

For details on default display names consult the Javadoc for org.junit.jupiter.api.TestInfo#getDisplayName().

Note that display names are typically used for test reporting in IDEs and build tools and may contain spaces, special characters, and even emoji.

Annotations
@Override
getExecutableInvokerback to summary
public ExecutableInvoker getExecutableInvoker()

Implements org.junit.jupiter.api.extension.ExtensionContext.getExecutableInvoker.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getExecutableInvoker.

Get an ExecutableInvoker to invoke methods and constructors with support for dynamic resolution of parameters.

Annotations
@Override
getExecutionModeback to summary
public ExecutionMode getExecutionMode()

Implements org.junit.jupiter.api.extension.ExtensionContext.getExecutionMode.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getExecutionMode.

Get the ExecutionMode associated with the current test or container.

Annotations
@Override
getExtensionsback to summary
public <E extends Extension> List<E> getExtensions(Class<E> extensionType)

Implements org.junit.jupiter.engine.extension.ExtensionContextInternal.getExtensions.

Doc from org.junit.jupiter.engine.extension.ExtensionContextInternal.getExtensions.

Returns a list of registered extension at this context of the passed extensionType.

Annotations
@Override
getParentback to summary
public Optional<ExtensionContext> getParent()

Implements org.junit.jupiter.api.extension.ExtensionContext.getParent.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getParent.

Get the parent extension context, if available.

Annotations
@Override
getParentStoreback to summary
private NamespacedHierarchicalStore<Namespace> getParentStore(@Nullable ExtensionContext parent)
getPlatformExecutionModeback to summary
protected abstract Node.ExecutionMode getPlatformExecutionMode()
getRootback to summary
public ExtensionContext getRoot()

Implements org.junit.jupiter.api.extension.ExtensionContext.getRoot.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getRoot.

Get the root ExtensionContext.

Annotations
@Override
getStoreback to summary
public ExtensionContext.Store getStore(ExtensionContext.Namespace namespace)

Implements org.junit.jupiter.api.extension.ExtensionContext.getStore.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getStore.

Get the Store for the supplied Namespace.

Use getStore(Namespace.GLOBAL) to get the default, global Namespace.

A store is bound to its extension context lifecycle. When an extension context lifecycle ends it closes its associated store. All stored values that are instances of ExtensionContext.Store.CloseableResource are notified by invoking their close() methods.

Annotations
@Override
getStoreback to summary
public ExtensionContext.Store getStore(ExtensionContext.StoreScope scope, ExtensionContext.Namespace namespace)

Implements org.junit.jupiter.api.extension.ExtensionContext.getStore.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getStore.

Returns the store for supplied scope and namespace.

If scope is EXTENSION_CONTEXT, the store behaves exactly like the one returned by getStore(Namespace). If the scope is LAUNCHER_SESSION or EXECUTION_REQUEST, all stored values that are instances of AutoCloseable are notified by invoking their close() methods when the scope is closed.

Annotations
@Override
getTagsback to summary
public Set<String> getTags()

Implements org.junit.jupiter.api.extension.ExtensionContext.getTags.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getTags.

Get the set of all tags for the current test or container.

Tags may be declared directly on the test element or inherited from an outer context.

Annotations
@Override
getTestDescriptorback to summary
protected T getTestDescriptor()
getUniqueIdback to summary
public String getUniqueId()

Implements org.junit.jupiter.api.extension.ExtensionContext.getUniqueId.

Doc from org.junit.jupiter.api.extension.ExtensionContext.getUniqueId.

Get the unique ID of the current test or container.

Annotations
@Override
publishDirectoryback to summary
public void publishDirectory(String name, ThrowingConsumer<Path> action)

Implements org.junit.jupiter.api.extension.ExtensionContext.publishDirectory.

Doc from org.junit.jupiter.api.extension.ExtensionContext.publishDirectory.

Publish a directory with the supplied name written by the supplied action and attach it to the current test or container.

The directory will be resolved and created in the report output directory prior to invoking the supplied action, if it does not already exist.

Annotations
@Override
publishFileback to summary
public void publishFile(String name, MediaType mediaType, ThrowingConsumer<Path> action)

Implements org.junit.jupiter.api.extension.ExtensionContext.publishFile.

Doc from org.junit.jupiter.api.extension.ExtensionContext.publishFile.

Publish a file with the supplied name written by the supplied action and attach it to the current test or container.

The file will be resolved in the report output directory prior to invoking the supplied action.

Annotations
@Override
publishFileEntryback to summary
private void publishFileEntry(String name, ThrowingConsumer<Path> action, Function<Path, FileEntry> fileEntryCreator)
publishReportEntryback to summary
public void publishReportEntry(Map<String, String> values)

Implements org.junit.jupiter.api.extension.ExtensionContext.publishReportEntry.

Doc from org.junit.jupiter.api.extension.ExtensionContext.publishReportEntry.

Publish a map of key-value pairs to be consumed by an org.junit.platform.engine.EngineExecutionListener in order to supply additional information to the reporting infrastructure.

Annotations
@Override
toJupiterExecutionModeback to summary
private ExecutionMode toJupiterExecutionMode(Node.ExecutionMode mode)