abstract class AbstractExtensionContext<T extends TestDescriptor> extends java.lang.Object implements ExtensionContext, java.lang.AutoCloseable
ExtensionContext.Namespace, ExtensionContext.Store| Modifier and Type | Field and Description |
|---|---|
private static NamespacedHierarchicalStore.CloseAction<ExtensionContext.Namespace> |
CLOSE_RESOURCES |
private JupiterConfiguration |
configuration |
private EngineExecutionListener |
engineExecutionListener |
private ExecutableInvoker |
executableInvoker |
private ExtensionContext |
parent |
private java.util.Set<java.lang.String> |
tags |
private T |
testDescriptor |
private NamespacedHierarchicalStore<ExtensionContext.Namespace> |
valuesStore |
| Constructor and Description |
|---|
AbstractExtensionContext(ExtensionContext parent,
EngineExecutionListener engineExecutionListener,
T testDescriptor,
JupiterConfiguration configuration,
ExecutableInvoker executableInvoker) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
private NamespacedHierarchicalStore<ExtensionContext.Namespace> |
createStore(ExtensionContext parent) |
java.util.Optional<java.lang.String> |
getConfigurationParameter(java.lang.String key)
Get the configuration parameter stored under the specified
key. |
<V> java.util.Optional<V> |
getConfigurationParameter(java.lang.String key,
java.util.function.Function<java.lang.String,V> transformer)
Get and transform the configuration parameter stored under the specified
key using the specified transformer. |
java.lang.String |
getDisplayName()
Get the display name for the current test or container.
|
ExecutableInvoker |
getExecutableInvoker()
Get an
ExecutableInvoker to invoke methods and constructors
with support for dynamic resolution of parameters. |
ExecutionMode |
getExecutionMode()
Get the
ExecutionMode associated with the current test or container. |
java.util.Optional<ExtensionContext> |
getParent()
Get the parent extension context, if available.
|
protected abstract Node.ExecutionMode |
getPlatformExecutionMode() |
ExtensionContext |
getRoot()
Get the root
ExtensionContext. |
ExtensionContext.Store |
getStore(ExtensionContext.Namespace namespace)
Get the
ExtensionContext.Store for the supplied ExtensionContext.Namespace. |
java.util.Set<java.lang.String> |
getTags()
Get the set of all tags for the current test or container.
|
protected T |
getTestDescriptor() |
java.lang.String |
getUniqueId()
Get the unique ID of the current test or container.
|
void |
publishReportEntry(java.util.Map<java.lang.String,java.lang.String> values)
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 |
toJupiterExecutionMode(Node.ExecutionMode mode) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetElement, getExecutionException, getRequiredTestClass, getRequiredTestInstance, getRequiredTestInstances, getRequiredTestMethod, getTestClass, getTestInstance, getTestInstanceLifecycle, getTestInstances, getTestMethod, publishReportEntry, publishReportEntryprivate static final NamespacedHierarchicalStore.CloseAction<ExtensionContext.Namespace> CLOSE_RESOURCES
private final ExtensionContext parent
private final EngineExecutionListener engineExecutionListener
private final T extends TestDescriptor testDescriptor
private final java.util.Set<java.lang.String> tags
private final JupiterConfiguration configuration
private final NamespacedHierarchicalStore<ExtensionContext.Namespace> valuesStore
private final ExecutableInvoker executableInvoker
AbstractExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener, T testDescriptor, JupiterConfiguration configuration, ExecutableInvoker executableInvoker)
private NamespacedHierarchicalStore<ExtensionContext.Namespace> createStore(ExtensionContext parent)
public void close()
close in interface java.lang.AutoCloseablepublic java.lang.String getUniqueId()
ExtensionContextgetUniqueId in interface ExtensionContextnull or blankpublic java.lang.String getDisplayName()
ExtensionContextThe display name is either a default name or a custom name configured
via @DisplayName.
For details on default display names consult the Javadoc for
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.
getDisplayName in interface ExtensionContextnull or blankpublic void publishReportEntry(java.util.Map<java.lang.String,java.lang.String> values)
ExtensionContextorg.junit.platform.engine.EngineExecutionListener in order to
supply additional information to the reporting infrastructure.publishReportEntry in interface ExtensionContextvalues - the key-value pairs to be published; never null;
keys and values within entries in the map also must not be
null or blankExtensionContext.publishReportEntry(String, String),
ExtensionContext.publishReportEntry(String),
EngineExecutionListener.reportingEntryPublished(org.junit.platform.engine.TestDescriptor, org.junit.platform.engine.reporting.ReportEntry)public java.util.Optional<ExtensionContext> getParent()
ExtensionContextgetParent in interface ExtensionContextOptional containing the parent; never null but
potentially emptyExtensionContext.getRoot()public ExtensionContext getRoot()
ExtensionContextExtensionContext.getRoot in interface ExtensionContextnull but potentially
this ExtensionContextExtensionContext.getParent()protected T getTestDescriptor()
public ExtensionContext.Store getStore(ExtensionContext.Namespace namespace)
ExtensionContextExtensionContext.Store for the supplied ExtensionContext.Namespace.
Use getStore(Namespace.GLOBAL) to get the default, global ExtensionContext.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.
getStore in interface ExtensionContextnamespace - the Namespace to get the store for; never nullnullExtensionContext.Namespace.GLOBALpublic java.util.Set<java.lang.String> getTags()
ExtensionContextTags may be declared directly on the test element or inherited from an outer context.
getTags in interface ExtensionContextnull but
potentially emptypublic java.util.Optional<java.lang.String> getConfigurationParameter(java.lang.String key)
ExtensionContextkey.
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.
getConfigurationParameter in interface ExtensionContextkey - the key to look up; never null or blankOptional containing the value; never null
but potentially emptySystem.getProperty(String),
ConfigurationParameterspublic <V> java.util.Optional<V> getConfigurationParameter(java.lang.String key,
java.util.function.Function<java.lang.String,V> transformer)
ExtensionContextkey 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
JUnitException with a helpful message.
getConfigurationParameter in interface ExtensionContextkey - the key to look up; never null or blanktransformer - the transformer to apply in case a value is found;
never nullOptional containing the value; never null
but potentially emptySystem.getProperty(String),
ConfigurationParameterspublic ExecutionMode getExecutionMode()
ExtensionContextExecutionMode associated with the current test or container.getExecutionMode in interface ExtensionContextExecutionMode of the test; never null{@code @ExecutionMode}public ExecutableInvoker getExecutableInvoker()
ExtensionContextExecutableInvoker to invoke methods and constructors
with support for dynamic resolution of parameters.getExecutableInvoker in interface ExtensionContextprotected abstract Node.ExecutionMode getPlatformExecutionMode()
private ExecutionMode toJupiterExecutionMode(Node.ExecutionMode mode)