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
@Autowired
SessionManager objectUnderTest
+ @Autowired
+ CpsSessionFactory cpsSessionFactory
+
def sessionId
def shortTimeoutForTesting = 200L
}
def cleanup(){
- objectUnderTest.closeSession(sessionId)
+ objectUnderTest.closeSession(sessionId, objectUnderTest.WITH_COMMIT)
}
@Sql([CLEAR_DATA, SET_DATA])
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()
+ }
+
}