Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide mechanism for managing resources across engines and executions #4281

Open
wants to merge 99 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
66891a5
Generate ResourceContext for store resources
YongGoose Dec 22, 2024
7b8182c
Add getStore method in LauncherSession
YongGoose Dec 22, 2024
d475bcf
Add Namespace by reusing Jupiter's Namespace class
YongGoose Jan 6, 2025
f25bec2
Apply comment
YongGoose Jan 18, 2025
7068fff
Adding a request-level store to Launcher
YongGoose Jan 19, 2025
dea6ecc
Apply comment
YongGoose Jan 27, 2025
d940bd4
Generate ResourceContext for store resources
YongGoose Dec 22, 2024
faebb0c
Add Namespace by reusing Jupiter's Namespace class
YongGoose Jan 6, 2025
365228d
Apply comment
YongGoose Jan 18, 2025
6018ff2
Adding a request-level store to Launcher
YongGoose Jan 19, 2025
552cb0b
Apply comment
YongGoose Jan 27, 2025
715a891
Revert "Apply comment"
YongGoose Jan 27, 2025
170c5dc
Apply comment
YongGoose Jan 27, 2025
a286eff
Update junit-platform-engine/src/main/java/org/junit/platform/engine/…
YongGoose Feb 12, 2025
622c366
Update junit-platform-launcher/src/main/java/org/junit/platform/launc…
YongGoose Feb 12, 2025
24b390b
Add API annotation
YongGoose Feb 12, 2025
89a3e4d
Move Namespace class
YongGoose Feb 12, 2025
9f25956
Apply comment
YongGoose Feb 12, 2025
9a1d5be
Apply Namespace parameter
YongGoose Feb 13, 2025
6e46c70
Outline management of session-/request-level stores
marcphilipp Feb 16, 2025
2cf6c7b
Use session-/request-level store in Jupiter engine
marcphilipp Feb 16, 2025
e4baa4b
Use request-level store as parent of engine-level store
marcphilipp Feb 16, 2025
8534a08
fixup! Outline management of session-/request-level stores
marcphilipp Feb 16, 2025
533adef
Fix test
marcphilipp Feb 16, 2025
46c1daf
Fix ExecutionRequest's `NamespacedHierarchicalStore`
YongGoose Feb 18, 2025
10be1e9
Fix post-merge compile error
marcphilipp Feb 24, 2025
f94624a
Limit session-/request-level store availability to execution
marcphilipp Feb 24, 2025
7ed2ab9
Remove broken Javadoc link
marcphilipp Feb 24, 2025
bd574d9
Revert changes
YongGoose Feb 25, 2025
ebe7966
Add JupiterEngineTests
YongGoose Feb 27, 2025
1b23aeb
Add NamespaceTests
YongGoose Mar 3, 2025
3b3d227
polishing
YongGoose Mar 8, 2025
bfca3ab
Merge branch 'main' into feature/2816
YongGoose Mar 9, 2025
6b6ca12
Apply comment
YongGoose Mar 9, 2025
d2f9f98
Add SuiteEngineTest
YongGoose Mar 9, 2025
370bc6d
Add EngineTestKitTest
YongGoose Mar 9, 2025
fff3109
Add LauncherStoreFacadeTest
YongGoose Mar 9, 2025
7b49ff3
Merge branch 'main' into feature/2816
YongGoose Mar 10, 2025
7151fbd
Merge branch 'main' into feature/2816
YongGoose Mar 10, 2025
f80a176
Update junit-jupiter-api/src/main/java/org/junit/jupiter/api/extensio…
YongGoose Mar 10, 2025
65c710b
Update junit-jupiter-api/src/main/java/org/junit/jupiter/api/extensio…
YongGoose Mar 10, 2025
a6dca82
Update junit-jupiter-api/src/main/java/org/junit/jupiter/api/extensio…
YongGoose Mar 10, 2025
7fb5b18
Update junit-jupiter-api/src/main/java/org/junit/jupiter/api/extensio…
YongGoose Mar 10, 2025
bb3a61d
Add Api annotation
YongGoose Mar 10, 2025
78a6023
Introduce create(List) method in Namespace
YongGoose Mar 10, 2025
10c052a
Update junit-platform-engine/src/main/java/org/junit/platform/engine/…
YongGoose Mar 10, 2025
fb4e4d7
Revert changes
YongGoose Mar 10, 2025
f461eb3
Merge branch 'main' into feature/2816
YongGoose Mar 10, 2025
c5c07f4
Resolve conflict
YongGoose Mar 10, 2025
f3d570e
Refactoring test codes
YongGoose Mar 10, 2025
66adb2c
Update jupiter-tests/src/test/java/org/junit/jupiter/engine/descripto…
YongGoose Mar 11, 2025
30505d0
Update jupiter-tests/src/test/java/org/junit/jupiter/engine/descripto…
YongGoose Mar 11, 2025
b40b864
Update jupiter-tests/src/test/java/org/junit/jupiter/engine/descripto…
YongGoose Mar 11, 2025
c3083f4
Update junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/de…
YongGoose Mar 11, 2025
13c03de
Merge branch 'main' into feature/2816
YongGoose Mar 11, 2025
579c492
Merge branch 'main' into feature/2816
YongGoose Mar 13, 2025
3aae750
polishing
YongGoose Mar 16, 2025
59d7d0c
update tests
YongGoose Mar 16, 2025
64186b9
Merge branch 'main' into feature/2816
YongGoose Mar 17, 2025
82a4e97
Merge branch 'main' into feature/2816
YongGoose Mar 17, 2025
b76ee64
polishing
YongGoose Mar 17, 2025
6f4fc2b
Add Jupiter extension test
YongGoose Mar 17, 2025
1683573
Add dummy test engines tests
YongGoose Mar 17, 2025
478ef7d
Merge branch 'main' into feature/2816
YongGoose Mar 18, 2025
0ee7f84
Merge branch 'main' into feature/2816
YongGoose Mar 18, 2025
45a6037
Update platform-tests/src/test/java/org/junit/platform/launcher/core/…
YongGoose Mar 18, 2025
7e65f7f
Merge branch 'main' into feature/2816
YongGoose Mar 18, 2025
5e98c47
Apply comment
YongGoose Mar 18, 2025
bb2f9ed
Merge branch 'main' into feature/2816
YongGoose Mar 19, 2025
dd33bf2
Refactor `ClassExtensionContext`
YongGoose Mar 19, 2025
a2feefc
Refactor `Namespace`
YongGoose Mar 19, 2025
4a650a9
Refactor `ExtensionContextTests`
YongGoose Mar 19, 2025
0d8f63d
Refactor `JupiterTestEngineTests`
YongGoose Mar 19, 2025
e29bb85
Apply comments
YongGoose Mar 19, 2025
8185507
Update junit-platform-launcher/src/testFixtures/java/org/junit/platfo…
YongGoose Mar 22, 2025
6625f24
Update junit-platform-engine/src/main/java/org/junit/platform/engine/…
YongGoose Mar 22, 2025
5ddaa93
Update junit-platform-engine/src/main/java/org/junit/platform/engine/…
YongGoose Mar 22, 2025
b85d29f
Update junit-platform-engine/src/main/java/org/junit/platform/engine/…
YongGoose Mar 22, 2025
a6b9896
Update platform-tests/src/test/java/org/junit/platform/suite/engine/S…
YongGoose Mar 22, 2025
b1b642a
Apply comments
YongGoose Mar 22, 2025
475b354
Merge branch 'main' into feature/2816
YongGoose Mar 22, 2025
85019a3
Apply comments
YongGoose Mar 22, 2025
efaace0
Update `LauncherFactoryTests`
YongGoose Mar 22, 2025
81492f3
Update `JupiterTestEngineTests`
YongGoose Mar 22, 2025
e5a5260
Ensure AutoCloseable resources are automatically closed
YongGoose Mar 22, 2025
b0456ec
polishing
YongGoose Mar 22, 2025
efc2f40
polishing
YongGoose Mar 23, 2025
9517474
Change extension to AfterTestExecutionCallback
YongGoose Mar 23, 2025
c1ce74a
Make `closed` flag of the resource static
YongGoose Mar 24, 2025
17ee313
Merge branch 'main' into feature/2816
YongGoose Mar 24, 2025
406b7e4
Merge branch 'main' into feature/2816
YongGoose Mar 24, 2025
45d4a1d
Update user-guide
YongGoose Mar 24, 2025
4eb741d
Revise User Guide sample
marcphilipp Mar 24, 2025
7c4e5f6
Update platform-tests/src/test/java/org/junit/platform/launcher/core/…
YongGoose Mar 24, 2025
0ac066c
Update platform-tests/src/test/java/org/junit/platform/launcher/core/…
YongGoose Mar 24, 2025
ad6fae0
Update platform-tests/src/test/java/org/junit/platform/launcher/core/…
YongGoose Mar 25, 2025
a367dd9
Update platform-tests/src/test/java/org/junit/platform/launcher/core/…
YongGoose Mar 25, 2025
219a194
Merge branch 'main' into feature/2816
YongGoose Mar 25, 2025
1de6773
Merge branch 'main' into feature/2816
YongGoose Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

package org.junit.jupiter.api.extension;

import static java.util.Collections.unmodifiableList;
import static org.apiguardian.api.API.Status.EXPERIMENTAL;
import static org.apiguardian.api.API.Status.INTERNAL;
import static org.apiguardian.api.API.Status.STABLE;

import java.lang.reflect.AnnotatedElement;
Expand Down Expand Up @@ -445,6 +447,49 @@ default void publishReportEntry(String value) {
*/
Store getStore(Namespace namespace);

/**
* Returns the store for session-level data.
*
* <p>This store may be used to store and retrieve data that is scoped to
* the current {@code LauncherSession}. Any data that is stored in this
* store will be available throughout the entire session. Therefore, it may
* be used to inject values from registered {@code LauncherSessionListener}
* implementations, to share data across multiple executions of the Jupiter
* engine within the same session, or even to share data across multiple
* engines.
*
* <p>Contrary to the regular {@code Store} instances returned by
* {@link #getStore(Namespace)}, all stored values that are instances of
* {@link AutoCloseable} are notified by invoking their {@code close()}
* methods when the session is closed.
*
* @return the store for session-level data
* @since 5.13
* @see org.junit.platform.launcher.LauncherSession
* @see org.junit.platform.launcher.LauncherSessionListener
*/
@API(status = EXPERIMENTAL, since = "5.13")
Store getSessionLevelStore(Namespace namespace);

/**
* Returns the store for request-level data.
*
* <p>This store may be used to store and retrieve data that is scoped to
* the current {@code ExecutionRequest}. Any data that is stored in this
* store will be available for the duration of the current request.
* Therefore, it may be used to share data across multiple engines.
*
* <p>Contrary to the regular {@code Store} instances returned by
* {@link #getStore(Namespace)}, all stored values that are instances of
* {@link AutoCloseable} are notified by invoking their {@code close()}
* methods when the execution request is completed.
*
* @return the store for request-level data
* @since 5.13
*/
@API(status = EXPERIMENTAL, since = "5.13")
Store getRequestLevelStore(Namespace namespace);

/**
* Get the {@link ExecutionMode} associated with the current test or container.
*
Expand Down Expand Up @@ -771,6 +816,11 @@ public Namespace append(Object... parts) {
Collections.addAll(newParts, parts);
return new Namespace(newParts);
}

@API(status = INTERNAL, since = "5.13")
public List<Object> getParts() {
return unmodifiableList(parts);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.jupiter.engine.config.DefaultJupiterConfiguration;
import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor;
import org.junit.jupiter.engine.descriptor.LauncherStoreFacade;
import org.junit.jupiter.engine.discovery.DiscoverySelectorResolver;
import org.junit.jupiter.engine.execution.JupiterEngineExecutionContext;
import org.junit.jupiter.engine.support.JupiterThrowableCollectorFactory;
Expand Down Expand Up @@ -82,8 +83,8 @@ protected HierarchicalTestExecutorService createExecutorService(ExecutionRequest

@Override
protected JupiterEngineExecutionContext createExecutionContext(ExecutionRequest request) {
return new JupiterEngineExecutionContext(request.getEngineExecutionListener(),
getJupiterConfiguration(request));
return new JupiterEngineExecutionContext(request.getEngineExecutionListener(), getJupiterConfiguration(request),
new LauncherStoreFacade(request.getRequestLevelStore()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.junit.jupiter.api.parallel.ExecutionMode;
import org.junit.jupiter.engine.config.JupiterConfiguration;
import org.junit.jupiter.engine.execution.DefaultExecutableInvoker;
import org.junit.jupiter.engine.execution.NamespaceAwareStore;
import org.junit.jupiter.engine.extension.ExtensionContextInternal;
import org.junit.jupiter.engine.extension.ExtensionRegistry;
import org.junit.platform.commons.JUnitException;
Expand All @@ -52,7 +51,8 @@
*/
abstract class AbstractExtensionContext<T extends TestDescriptor> implements ExtensionContextInternal, AutoCloseable {

private static final NamespacedHierarchicalStore.CloseAction<Namespace> CLOSE_RESOURCES = (__, ___, value) -> {
private static final NamespacedHierarchicalStore.CloseAction<org.junit.platform.engine.support.store.Namespace> CLOSE_RESOURCES = (
__, ___, value) -> {
if (value instanceof CloseableResource) {
((CloseableResource) value).close();
}
Expand All @@ -63,12 +63,14 @@ abstract class AbstractExtensionContext<T extends TestDescriptor> implements Ext
private final T testDescriptor;
private final Set<String> tags;
private final JupiterConfiguration configuration;
private final NamespacedHierarchicalStore<Namespace> valuesStore;
private final NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace> valuesStore;
private final ExecutableInvoker executableInvoker;
private final ExtensionRegistry extensionRegistry;
private final LauncherStoreFacade launcherStoreFacade;

AbstractExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener, T testDescriptor,
JupiterConfiguration configuration, ExtensionRegistry extensionRegistry) {
JupiterConfiguration configuration, ExtensionRegistry extensionRegistry,
LauncherStoreFacade launcherStoreFacade) {

Preconditions.notNull(testDescriptor, "TestDescriptor must not be null");
Preconditions.notNull(configuration, "JupiterConfiguration must not be null");
Expand All @@ -78,8 +80,9 @@ abstract class AbstractExtensionContext<T extends TestDescriptor> implements Ext
this.engineExecutionListener = engineExecutionListener;
this.testDescriptor = testDescriptor;
this.configuration = configuration;
this.valuesStore = createStore(parent);
this.valuesStore = createStore(parent, launcherStoreFacade);
this.extensionRegistry = extensionRegistry;
this.launcherStoreFacade = launcherStoreFacade;

// @formatter:off
this.tags = testDescriptor.getTags().stream()
Expand All @@ -88,9 +91,13 @@ abstract class AbstractExtensionContext<T extends TestDescriptor> implements Ext
// @formatter:on
}

private static NamespacedHierarchicalStore<Namespace> createStore(ExtensionContext parent) {
NamespacedHierarchicalStore<Namespace> parentStore = null;
if (parent != null) {
private static NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace> createStore(
ExtensionContext parent, LauncherStoreFacade launcherStoreFacade) {
NamespacedHierarchicalStore<org.junit.platform.engine.support.store.Namespace> parentStore;
if (parent == null) {
parentStore = launcherStoreFacade.getRequestLevelStore();
}
else {
parentStore = ((AbstractExtensionContext<?>) parent).valuesStore;
}
return new NamespacedHierarchicalStore<>(parentStore, CLOSE_RESOURCES);
Expand Down Expand Up @@ -188,8 +195,17 @@ protected T getTestDescriptor() {

@Override
public Store getStore(Namespace namespace) {
Preconditions.notNull(namespace, "Namespace must not be null");
return new NamespaceAwareStore(this.valuesStore, namespace);
return launcherStoreFacade.getStoreAdapter(this.valuesStore, namespace);
}

@Override
public Store getSessionLevelStore(Namespace namespace) {
return launcherStoreFacade.getSessionLevelStore(namespace);
}

@Override
public Store getRequestLevelStore(Namespace namespace) {
return launcherStoreFacade.getRequestLevelStore(namespace);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public final JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext
ThrowableCollector throwableCollector = createThrowableCollector();
ClassExtensionContext extensionContext = new ClassExtensionContext(context.getExtensionContext(),
context.getExecutionListener(), this, this.classInfo.lifecycle, context.getConfiguration(), registry,
throwableCollector);
context.getLauncherStoreFacade(), throwableCollector);

// @formatter:off
return context.extend()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,26 @@ final class ClassExtensionContext extends AbstractExtensionContext<ClassBasedTes

private TestInstances testInstances;

/**
* Create a new {@code ClassExtensionContext} with {@link Lifecycle#PER_METHOD}.
*
* @see #ClassExtensionContext(ExtensionContext, EngineExecutionListener, ClassBasedTestDescriptor, Lifecycle, JupiterConfiguration, ExtensionRegistry, LauncherStoreFacade, ThrowableCollector)
*/
ClassExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener,
ClassBasedTestDescriptor testDescriptor, JupiterConfiguration configuration,
ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade,
ThrowableCollector throwableCollector) {

this(parent, engineExecutionListener, testDescriptor, Lifecycle.PER_METHOD, configuration, extensionRegistry,
launcherStoreFacade, throwableCollector);
}

ClassExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener,
ClassBasedTestDescriptor testDescriptor, Lifecycle lifecycle, JupiterConfiguration configuration,
ExtensionRegistry extensionRegistry, ThrowableCollector throwableCollector) {
ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade,
ThrowableCollector throwableCollector) {

super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry);
super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry, launcherStoreFacade);

this.lifecycle = lifecycle;
this.throwableCollector = throwableCollector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ final class ClassTemplateInvocationExtensionContext

ClassTemplateInvocationExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener,
ClassTemplateInvocationTestDescriptor testDescriptor, JupiterConfiguration configuration,
ExtensionRegistry extensionRegistry) {
super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry);
ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade) {
super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry, launcherStoreFacade);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext conte
registry = childRegistry;
}
ExtensionContext extensionContext = new ClassTemplateInvocationExtensionContext(context.getExtensionContext(),
context.getExecutionListener(), this, context.getConfiguration(), registry);
context.getExecutionListener(), this, context.getConfiguration(), registry,
context.getLauncherStoreFacade());
ThrowableCollector throwableCollector = createThrowableCollector();
throwableCollector.execute(() -> this.invocationContext.prepareInvocation(extensionContext));
return context.extend() //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class DynamicExtensionContext extends AbstractExtensionContext<DynamicNodeTestDe

DynamicExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener,
DynamicNodeTestDescriptor testDescriptor, JupiterConfiguration configuration,
ExtensionRegistry extensionRegistry) {
super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry);
ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade) {
super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry, launcherStoreFacade);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public String getLegacyReportingName() {
@Override
public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext context) {
ExtensionContext extensionContext = new DynamicExtensionContext(context.getExtensionContext(),
context.getExecutionListener(), this, context.getConfiguration(), context.getExtensionRegistry());
context.getExecutionListener(), this, context.getConfiguration(), context.getExtensionRegistry(),
context.getLauncherStoreFacade());
// @formatter:off
return context.extend()
.withExtensionContext(extensionContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext conte
context.getConfiguration());
EngineExecutionListener executionListener = context.getExecutionListener();
ExtensionContext extensionContext = new JupiterEngineExtensionContext(executionListener, this,
context.getConfiguration(), extensionRegistry);
context.getConfiguration(), extensionRegistry, context.getLauncherStoreFacade());

// @formatter:off
return context.extend()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ final class JupiterEngineExtensionContext extends AbstractExtensionContext<Jupit

JupiterEngineExtensionContext(EngineExecutionListener engineExecutionListener,
JupiterEngineDescriptor testDescriptor, JupiterConfiguration configuration,
ExtensionRegistry extensionRegistry) {
ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade) {

super(null, engineExecutionListener, testDescriptor, configuration, extensionRegistry);
super(null, engineExecutionListener, testDescriptor, configuration, extensionRegistry, launcherStoreFacade);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2015-2025 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* https://www.eclipse.org/legal/epl-v20.html
*/

package org.junit.jupiter.engine.descriptor;

import static org.apiguardian.api.API.Status.INTERNAL;

import org.apiguardian.api.API;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.engine.execution.NamespaceAwareStore;
import org.junit.platform.commons.JUnitException;
import org.junit.platform.commons.util.Preconditions;
import org.junit.platform.engine.support.store.Namespace;
import org.junit.platform.engine.support.store.NamespacedHierarchicalStore;

@API(status = INTERNAL, since = "5.13")
public class LauncherStoreFacade {

private final NamespacedHierarchicalStore<Namespace> requestLevelStore;
private final NamespacedHierarchicalStore<Namespace> sessionLevelStore;

public LauncherStoreFacade(NamespacedHierarchicalStore<Namespace> requestLevelStore) {
this.requestLevelStore = requestLevelStore;
this.sessionLevelStore = requestLevelStore.getParent().orElseThrow(
() -> new JUnitException("Request-level store must have a parent"));
}

NamespacedHierarchicalStore<Namespace> getRequestLevelStore() {
return this.requestLevelStore;
}

ExtensionContext.Store getRequestLevelStore(ExtensionContext.Namespace namespace) {
return getStoreAdapter(this.requestLevelStore, namespace);
}

ExtensionContext.Store getSessionLevelStore(ExtensionContext.Namespace namespace) {
return getStoreAdapter(this.sessionLevelStore, namespace);
}

NamespaceAwareStore getStoreAdapter(NamespacedHierarchicalStore<Namespace> valuesStore,
ExtensionContext.Namespace namespace) {
Preconditions.notNull(namespace, "Namespace must not be null");
return new NamespaceAwareStore(valuesStore, convert(namespace));
}

private Namespace convert(ExtensionContext.Namespace namespace) {
return namespace.equals(ExtensionContext.Namespace.GLOBAL) //
? Namespace.GLOBAL //
: Namespace.create(namespace.getParts());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ final class MethodExtensionContext extends AbstractExtensionContext<TestMethodTe

MethodExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener,
TestMethodTestDescriptor testDescriptor, JupiterConfiguration configuration,
ExtensionRegistry extensionRegistry, ThrowableCollector throwableCollector) {
ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade,
ThrowableCollector throwableCollector) {

super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry);
super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry, launcherStoreFacade);

this.throwableCollector = throwableCollector;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext conte
MutableExtensionRegistry registry = populateNewExtensionRegistry(context);
ThrowableCollector throwableCollector = createThrowableCollector();
MethodExtensionContext extensionContext = new MethodExtensionContext(context.getExtensionContext(),
context.getExecutionListener(), this, context.getConfiguration(), registry, throwableCollector);
context.getExecutionListener(), this, context.getConfiguration(), registry,
context.getLauncherStoreFacade(), throwableCollector);
// @formatter:off
JupiterEngineExecutionContext newContext = context.extend()
.withExtensionRegistry(registry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ final class TestTemplateExtensionContext extends AbstractExtensionContext<TestTe

TestTemplateExtensionContext(ExtensionContext parent, EngineExecutionListener engineExecutionListener,
TestTemplateTestDescriptor testDescriptor, JupiterConfiguration configuration,
ExtensionRegistry extensionRegistry, TestInstances testInstances) {
ExtensionRegistry extensionRegistry, LauncherStoreFacade launcherStoreFacade, TestInstances testInstances) {

super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry);
super(parent, engineExecutionListener, testDescriptor, configuration, extensionRegistry, launcherStoreFacade);
this.testInstances = testInstances;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public JupiterEngineExecutionContext prepare(JupiterEngineExecutionContext conte
TestInstances testInstances = context.getExtensionContext().getTestInstances().orElse(null);

ExtensionContext extensionContext = new TestTemplateExtensionContext(context.getExtensionContext(),
context.getExecutionListener(), this, context.getConfiguration(), registry, testInstances);
context.getExecutionListener(), this, context.getConfiguration(), registry,
context.getLauncherStoreFacade(), testInstances);

// @formatter:off
return context.extend()
Expand Down
Loading