summaryrefslogtreecommitdiffstats
path: root/feature-distributed-locking/src/test/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-07-18 13:49:42 -0400
committerJim Hahn <jrh3@att.com>2018-07-18 14:54:29 -0400
commite8f1b7235f8338fbb9eba28d8cff29d3d6adf6e7 (patch)
treea71afb05855a68ef5ada2ffffaab74ab901b8ae4 /feature-distributed-locking/src/test/java
parent6d7f829afe8e91d2c1cf33ec8dc770a515c9959d (diff)
Deny subsequent lock()
This is the final step of separating the lock "refresh" operation from the original "lock" operation. This step entails rejecting subsequent "lock" requests, even by the same owner, when a resource is already locked; "refresh" should now be used, instead, to extend a lock. Modified comments to indicate that the lock can only be extended using "refresh". Change-Id: I406cf60c076dbce87afbd94fb301732359dbd2db Issue-ID: POLICY-872 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-distributed-locking/src/test/java')
-rw-r--r--feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
index 6e33f224..42c8a742 100644
--- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
+++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java
@@ -92,8 +92,10 @@ public class TargetLockTest {
assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
- // extend the lock
- assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
+ // cannot re-lock
+ assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeLock("resource1", "owner1", MAX_AGE_SEC));
+
+ assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
}
@Test
@@ -131,6 +133,8 @@ public class TargetLockTest {
// refresh should work now
assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
+ assertEquals(OperResult.OPER_ACCEPTED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
+
// expire the lock
try (PreparedStatement updateStatement = conn.prepareStatement("UPDATE pooling.locks SET expirationTime = timestampadd(second, -1, now()) WHERE resourceId = ?");)
{
@@ -144,6 +148,8 @@ public class TargetLockTest {
// refresh should fail now
assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeRefresh("resource1", "owner1", MAX_AGE_SEC));
+
+ assertEquals(OperResult.OPER_DENIED, distLockFeat.beforeIsLockedBy("resource1", "owner1"));
}