X-Git-Url: https://gerrit.onap.org/r/gitweb?p=cps.git;a=blobdiff_plain;f=cps-ri%2Fsrc%2Ftest%2Fgroovy%2Forg%2Fonap%2Fcps%2Fspi%2Futils%2FSessionManagerIntegrationSpec.groovy;h=a1f6d580fd6b3d4a2040bc904071f196c25d06fe;hp=9b58c8bc3231378393b04cfeeff326f9f381a924;hb=0b80343610a215f26a7d764cc849f8e9ca44fea0;hpb=ac5ae3e24e347bb6d643e9b4e5ebcf3baa7152a2 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() + } + }