ResourceLocksProvider is 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 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.
ResourceLock#providers(), Resources, ResourceAccessMode, Lock
| Modifier and Type | Class and Description |
|---|---|
| public static class | ResourceLocksProvider.
|
| Modifier and Type | Method and Description |
|---|---|
| public default Set | Returns: a set ofLock; may be emptya test class for which to add shared resources testClass)Add shared resources for a test class. |
| public default Set | Returns: a set ofLock; may be emptythe runtime types of the enclosing
instances for the test class, ordered from outermost to innermost,
excluding enclosingInstanceTypes, Class<?> testClass; never nullthe test class or testClass, Method @Nested
test class that contains the testMethoda test method for which to add shared resources testMethod)Add shared resources for a test method. |
| public default Set | Returns: a set ofLock; may be emptythe runtime types of the enclosing
instances for the test class, ordered from outermost to innermost,
excluding enclosingInstanceTypes, Class<?> testClass; never nulla nested test class for which to add shared resources testClass)Add shared resources for a
|
| provideForClass | back to summary |
|---|---|
| public default Set Add shared resources for a test class. Invoked in case a test class or its parent class is annotated with
API Note Adding a shared resource via this method has
the same semantics as annotating a test class with an analogous
| |
| provideForMethod | back to summary |
|---|---|
| public default Set Add shared resources for a test method. Invoked in case:
API Note Adding a shared resource with this method
has the same semantics as annotating a test method
with analogous Implementation Note The classes supplied as
| |
| provideForNestedClass | back to summary |
|---|---|
| public default Set Add shared resources for a
Invoked in case:
API Note Adding a shared resource via this method has
the same semantics as annotating a nested test class with an analogous
Implementation Note The classes supplied as
| |
Lock represents a shared resource.
Each resource is identified by a key. In addition,
the access mode allows one to specify whether
a test class or test method requires READ_WRITE or READ access to the resource.
API Note
getKey() and getAccessMode() have the same
semantics as ResourceLock#value() and ResourceLock#mode()
respectively.
Isolated, Resources, ResourceAccessMode, ResourceLock, ResourceLocksProvider
| Modifier and Type | Field and Description |
|---|---|
| private final ResourceAccessMode | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public | Lock(String
the identifier of the resource; never key)null or blankCreate a new |
| public | Lock(String
the identifier of the resource; never key, ResourceAccessMode null or blankthe lock mode to use to synchronize access to the
resource; never accessMode)nullCreate a new |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object o)
Overrides java. Indicates whether some other object is "equal to" this one. |
| public ResourceAccessMode | |
| public String | |
| public int | |
| public String |
| accessMode | back to summary |
|---|---|
| private final ResourceAccessMode accessMode | |
| key | back to summary |
|---|---|
| private final String key | |
| Lock | back to summary |
|---|---|
| public Lock(String key) Create a new
| |
| Lock | back to summary |
|---|---|
| public Lock(String key, ResourceAccessMode accessMode) Create a new
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| |
| getAccessMode | back to summary |
|---|---|
| public ResourceAccessMode getAccessMode() Get the access mode for this lock.
| |
| getKey | back to summary |
|---|---|
| public String getKey() Get the key for this lock.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |