Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCleanupNotUsedLocks()
        public virtual void ShouldCleanupNotUsedLocks()
        {
            // given
            LockResource    node            = new LockResource(ResourceTypes.NODE, 1L);
            LockTransaction lockTransaction = new LockTransaction();
            LockManagerImpl lockManager     = CreateLockManager();

            lockManager.GetWriteLock(LockTracer.NONE, node, lockTransaction);

            // expect
            assertTrue(lockManager.TryReadLock(node, lockTransaction));
            assertEquals(1, CountLocks(lockManager));

            // and when
            lockManager.ReleaseWriteLock(node, lockTransaction);

            // expect to see one old reader
            assertEquals(1, CountLocks(lockManager));

            // and when
            lockManager.ReleaseReadLock(node, lockTransaction);

            // no more locks left
            assertEquals(0, CountLocks(lockManager));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowGetReadWriteLocks()
        public virtual void ShouldAllowGetReadWriteLocks()
        {
            // given
            LockResource    node1           = new LockResource(ResourceTypes.NODE, 1L);
            LockResource    node2           = new LockResource(ResourceTypes.NODE, 2L);
            LockTransaction lockTransaction = new LockTransaction();
            LockManagerImpl lockManager     = CreateLockManager();

            // expect
            assertTrue(lockManager.GetReadLock(LockTracer.NONE, node1, lockTransaction));
            assertTrue(lockManager.GetReadLock(LockTracer.NONE, node2, lockTransaction));
            assertTrue(lockManager.GetWriteLock(LockTracer.NONE, node2, lockTransaction));

            lockManager.ReleaseReadLock(node1, lockTransaction);
            lockManager.ReleaseReadLock(node2, lockTransaction);
            lockManager.ReleaseWriteLock(node2, lockTransaction);

            int lockCount = CountLocks(lockManager);

            assertEquals(0, lockCount);
        }