Package org.junit.jupiter.api.parallel
Interface ResourceLocksProvider
-
@API(status=MAINTAINED, since="5.13.3") public interface ResourceLocksProviderAResourceLocksProvideris used to programmatically add shared resources to a test class or its test methods dynamically at runtime.Each shared resource is represented by an instance of
ResourceLocksProvider.Lock.Adding shared resources via this API has the same semantics as declaring them declaratively via
@ResourceLock(value, mode), but for some use cases the programmatic approach may be more flexible and less verbose.Implementations must provide a no-args constructor.
- Since:
- 5.12
- See Also:
ResourceLock.providers(),Resources,ResourceAccessMode,ResourceLocksProvider.Lock
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classResourceLocksProvider.LockLockrepresents a shared resource.
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default java.util.Set<ResourceLocksProvider.Lock>provideForClass(java.lang.Class<?> testClass)Add shared resources for a test class.default java.util.Set<ResourceLocksProvider.Lock>provideForMethod(java.util.List<java.lang.Class<?>> enclosingInstanceTypes, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)Add shared resources for a test method.default java.util.Set<ResourceLocksProvider.Lock>provideForNestedClass(java.util.List<java.lang.Class<?>> enclosingInstanceTypes, java.lang.Class<?> testClass)Add shared resources for a@Nestedtest class.
-
-
-
Method Detail
-
provideForClass
default java.util.Set<ResourceLocksProvider.Lock> provideForClass(java.lang.Class<?> testClass)
Add shared resources for a test class.Invoked in case a test class or its parent class is annotated with
@ResourceLock(providers).- Parameters:
testClass- a test class for which to add shared resources- Returns:
- a set of
ResourceLocksProvider.Lock; may be empty
-
provideForNestedClass
default java.util.Set<ResourceLocksProvider.Lock> provideForNestedClass(java.util.List<java.lang.Class<?>> enclosingInstanceTypes, java.lang.Class<?> testClass)
Add shared resources for a@Nestedtest class.Invoked in case:
- an enclosing test class of any level or its parent class is
annotated with
@ResourceLock(providers = ...). - a nested test class or its parent class is annotated with
@ResourceLock(providers = ...).
- Parameters:
enclosingInstanceTypes- the runtime types of the enclosing instances for the test class, ordered from outermost to innermost, excludingtestClass; nevernulltestClass- a nested test class for which to add shared resources- Returns:
- a set of
ResourceLocksProvider.Lock; may be empty - See Also:
@Nested
- an enclosing test class of any level or its parent class is
annotated with
-
provideForMethod
default java.util.Set<ResourceLocksProvider.Lock> provideForMethod(java.util.List<java.lang.Class<?>> enclosingInstanceTypes, java.lang.Class<?> testClass, java.lang.reflect.Method testMethod)
Add shared resources for a test method.Invoked in case:
- an enclosing test class of any level or its parent class is
annotated with
@ResourceLock(providers). - a test method is annotated with
@ResourceLock(providers).
- Parameters:
enclosingInstanceTypes- the runtime types of the enclosing instances for the test class, ordered from outermost to innermost, excludingtestClass; nevernulltestClass- the test class or@Nestedtest class that contains thetestMethodtestMethod- a test method for which to add shared resources- Returns:
- a set of
ResourceLocksProvider.Lock; may be empty - See Also:
@Nested
- an enclosing test class of any level or its parent class is
annotated with
-
-