- def 'close session that does not exist' (){
- given: 'session Id that does not exist'
- def unknownSessionId = 'unknown session id'
- when: 'close session method is called'
- objectUnderTest.closeSession(unknownSessionId)
- then: 'a session exception is thrown'
- def thrown = thrown(SessionException)
- assert thrown.message.contains(unknownSessionId)
+ @Sql([CLEAR_DATA, SET_DATA])
+ def 'Attempt to lock anchor when another session is holding the lock.'(){
+ given: 'another session that holds an anchor lock'
+ def otherSessionId = objectUnderTest.startSession()
+ objectUnderTest.lockAnchor(otherSessionId,DATASPACE_NAME,ANCHOR_NAME1,shortTimeoutForTesting)
+ when: 'a session tries to acquire the same anchor lock'
+ objectUnderTest.lockAnchor(sessionId,DATASPACE_NAME,ANCHOR_NAME1,shortTimeoutForTesting)
+ then: 'a session manager exception is thrown specifying operation reached timeout'
+ 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.WITH_COMMIT)
+ objectUnderTest.lockAnchor(sessionId,DATASPACE_NAME,ANCHOR_NAME1,shortTimeoutForTesting)