diff --git a/docs/extensions.adoc b/docs/extensions.adoc index 7dbb8b9099..bf2b63e3c3 100644 --- a/docs/extensions.adoc +++ b/docs/extensions.adoc @@ -1160,7 +1160,7 @@ Often, the state can be kept locally in the `intercept(IMethodInvocation)` metho Spock 2.4 adds a new `org.spockframework.runtime.extension.IStore` interface that allows extensions to store and retrieve data during the execution of a specification. -The store is available from the `org.spockframework.runtime.extension.IMethodInvocation` interface via the `getStore(IStore.Namespace namespace)` method. Currently, it is possible to access the store directly from an extension, only via a registering an <<#interceptors,interceptor>>. +The store is available from the `org.spockframework.runtime.extension.IMethodInvocation` interface via the `getStore(IStore.Namespace namespace)` method. Currently, it is not possible to access the store directly from an extension, only via registering an <<#interceptors,interceptor>>. The stores are hierarchical and follow roughly the same hierarchy as shown in the <> figure. The hierarchy is as follows: diff --git a/spock-core/src/main/java/org/spockframework/runtime/PlatformParameterizedSpecRunner.java b/spock-core/src/main/java/org/spockframework/runtime/PlatformParameterizedSpecRunner.java index 856bb7f20c..ac404132a2 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/PlatformParameterizedSpecRunner.java +++ b/spock-core/src/main/java/org/spockframework/runtime/PlatformParameterizedSpecRunner.java @@ -40,7 +40,7 @@ void runParameterizedFeature(SpockExecutionContext context, ParameterizedFeature return; } - context = context.withChildStore(); + context = context.withChildStoreProvider(); FeatureInfo feature = context.getCurrentFeature(); try (IDataIterator dataIterator = new DataIteratorFactory(supervisor).createFeatureDataIterator(context)) { IIterationRunner iterationRunner = createIterationRunner(context, childExecutor); @@ -52,7 +52,7 @@ void runParameterizedFeature(SpockExecutionContext context, ParameterizedFeature } catch (Exception e) { ExceptionUtil.sneakyThrow(e); } finally { - runCloseContextStore(context, MethodKind.CLEANUP); + runCloseContextStoreProvider(context, MethodKind.CLEANUP); } } diff --git a/spock-core/src/main/java/org/spockframework/runtime/PlatformSpecRunner.java b/spock-core/src/main/java/org/spockframework/runtime/PlatformSpecRunner.java index 8f0c1ab8cb..85d1a68f2b 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/PlatformSpecRunner.java +++ b/spock-core/src/main/java/org/spockframework/runtime/PlatformSpecRunner.java @@ -82,7 +82,7 @@ SpockExecutionContext createSpecInstance(SpockExecutionContext context, boolean } - context = context.withChildStore().withCurrentInstance(instance); + context = context.withChildStoreProvider().withCurrentInstance(instance); getSpecificationContext(context).setCurrentSpec(context.getSpec()); if (shared) { context = context.withSharedInstance(instance); @@ -151,7 +151,7 @@ public void doRunSetupSpec(SpockExecutionContext context, SpecInfo spec) { void runCleanupSpec(SpockExecutionContext context) { runCleanupSpec(context.withCurrentInstance(context.getSharedInstance()), context.getSpec()); - runCloseContextStore(context, MethodKind.CLEANUP_SPEC); + runCloseContextStoreProvider(context, MethodKind.CLEANUP_SPEC); } private void runCleanupSpec(SpockExecutionContext context, SpecInfo spec) { @@ -328,7 +328,7 @@ void runFeatureMethod(SpockExecutionContext context) { void runCleanup(SpockExecutionContext context) { runCleanup(context, context.getSpec()); - runCloseContextStore(context, MethodKind.CLEANUP); + runCloseContextStoreProvider(context, MethodKind.CLEANUP); } private void runCleanup(SpockExecutionContext context, SpecInfo spec) { @@ -373,12 +373,12 @@ private void runIterationCleanups(SpockExecutionContext context) { } } - void runCloseContextStore(SpockExecutionContext context, MethodKind kind) { - MethodInfo methodInfo = createMethodInfoForCloseContextStore(context, kind); + void runCloseContextStoreProvider(SpockExecutionContext context, MethodKind kind) { + MethodInfo methodInfo = createMethodInfoForCloseContextStoreProvider(context, kind); invokeRaw(context, context.getStoreProvider(), methodInfo); } - private MethodInfo createMethodInfoForCloseContextStore(SpockExecutionContext context, MethodKind kind) { + private MethodInfo createMethodInfoForCloseContextStoreProvider(SpockExecutionContext context, MethodKind kind) { MethodInfo result = new MethodInfo((Object target, Object... arguments) -> { context.getStoreProvider().close(); return null; diff --git a/spock-core/src/main/java/org/spockframework/runtime/SpockExecutionContext.java b/spock-core/src/main/java/org/spockframework/runtime/SpockExecutionContext.java index 2db7fce500..8ad95f5a08 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/SpockExecutionContext.java +++ b/spock-core/src/main/java/org/spockframework/runtime/SpockExecutionContext.java @@ -138,8 +138,8 @@ public SpockExecutionContext withParentId(UniqueId uniqueId) { return clone().setParentId(uniqueId); } - public SpockExecutionContext withChildStore() { - return clone().setStoreProvider(storeProvider.createChildStore()); + public SpockExecutionContext withChildStoreProvider() { + return clone().setStoreProvider(storeProvider.createChildStoreProvider()); } public Specification getSharedInstance() { diff --git a/spock-core/src/main/java/org/spockframework/runtime/StoreProvider.java b/spock-core/src/main/java/org/spockframework/runtime/StoreProvider.java index 19e72c64d5..98800b0065 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/StoreProvider.java +++ b/spock-core/src/main/java/org/spockframework/runtime/StoreProvider.java @@ -19,7 +19,7 @@ public static StoreProvider createRootStore() { return new StoreProvider(newBackendStore(null)); } - public StoreProvider createChildStore() { + public StoreProvider createChildStoreProvider() { return new StoreProvider(newBackendStore(backend)); } diff --git a/spock-core/src/main/java/org/spockframework/runtime/extension/IStore.java b/spock-core/src/main/java/org/spockframework/runtime/extension/IStore.java index c2ebb5c6a0..968f00c5c5 100644 --- a/spock-core/src/main/java/org/spockframework/runtime/extension/IStore.java +++ b/spock-core/src/main/java/org/spockframework/runtime/extension/IStore.java @@ -220,7 +220,7 @@ default V getOrComputeIfAbsent(Class type) { /** * A {@code Namespace} is used to provide a scope for data saved by - * extensions within a {@link IStore}. + * extensions within an {@link IStore}. * *

Storing data in custom namespaces allows extensions to avoid accidentally * mixing data between extensions or across different invocations within the