summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/test/groovy/org/onap/cps/spi/utils/SessionManagerIntegrationSpec.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ri/src/test/groovy/org/onap/cps/spi/utils/SessionManagerIntegrationSpec.groovy')
-rw-r--r--cps-ri/src/test/groovy/org/onap/cps/spi/utils/SessionManagerIntegrationSpec.groovy18
1 files changed, 16 insertions, 2 deletions
diff --git a/cps-ri/src/test/groovy/org/onap/cps/spi/utils/SessionManagerIntegrationSpec.groovy b/cps-ri/src/test/groovy/org/onap/cps/spi/utils/SessionManagerIntegrationSpec.groovy
index 9b58c8bc3..a1f6d580f 100644
--- a/cps-ri/src/test/groovy/org/onap/cps/spi/utils/SessionManagerIntegrationSpec.groovy
+++ b/cps-ri/src/test/groovy/org/onap/cps/spi/utils/SessionManagerIntegrationSpec.groovy
@@ -20,6 +20,7 @@
package org.onap.cps.spi.utils
+import org.onap.cps.spi.config.CpsSessionFactory
import org.onap.cps.spi.exceptions.SessionManagerException
import org.onap.cps.spi.impl.CpsPersistenceSpecBase
import org.springframework.beans.factory.annotation.Autowired
@@ -32,6 +33,9 @@ class SessionManagerIntegrationSpec extends CpsPersistenceSpecBase{
@Autowired
SessionManager objectUnderTest
+ @Autowired
+ CpsSessionFactory cpsSessionFactory
+
def sessionId
def shortTimeoutForTesting = 200L
@@ -40,7 +44,7 @@ class SessionManagerIntegrationSpec extends CpsPersistenceSpecBase{
}
def cleanup(){
- objectUnderTest.closeSession(sessionId)
+ objectUnderTest.closeSession(sessionId, objectUnderTest.WITH_COMMIT)
}
@Sql([CLEAR_DATA, SET_DATA])
@@ -62,8 +66,18 @@ class SessionManagerIntegrationSpec extends CpsPersistenceSpecBase{
def thrown = thrown(SessionManagerException)
thrown.message.contains('Timeout')
then: 'when the other session holding the lock is closed, lock can finally be acquired'
- objectUnderTest.closeSession(otherSessionId)
+ objectUnderTest.closeSession(otherSessionId, objectUnderTest.WITH_COMMIT)
objectUnderTest.lockAnchor(sessionId,DATASPACE_NAME,ANCHOR_NAME1,shortTimeoutForTesting)
}
+ @Sql([CLEAR_DATA, SET_DATA])
+ def 'Lock anchor twice using the same session.'(){
+ given: 'session that already holds an anchor lock'
+ objectUnderTest.lockAnchor(sessionId, DATASPACE_NAME, ANCHOR_NAME1, shortTimeoutForTesting)
+ when: 'same session tries to acquire same anchor lock'
+ objectUnderTest.lockAnchor(sessionId, DATASPACE_NAME, ANCHOR_NAME1, shortTimeoutForTesting)
+ then: 'no exception is thrown'
+ noExceptionThrown()
+ }
+
}