Exemple #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void exclusiveShouldWaitForShared()
        public virtual void ExclusiveShouldWaitForShared()
        {
            // When
            ClientA.acquireShared(LockTracer.NONE, NODE, 1L);

            // Then other shared locks are allowed
            ClientC.acquireShared(LockTracer.NONE, NODE, 1L);

            // But exclusive locks should wait
            Future <object> clientBLock = AcquireExclusive(ClientB, LockTracer.NONE, NODE, 1L).callAndAssertWaiting();

            // And when
            ClientA.releaseShared(NODE, 1L);
            ClientC.releaseShared(NODE, 1L);

            // Then this should not block
            AssertNotWaiting(ClientB, clientBLock);
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustReleaseWriteLockWaitersOnStop()
        public virtual void MustReleaseWriteLockWaitersOnStop()
        {
            // Given
            ClientA.acquireShared(_tracer, NODE, 1L);
            ClientB.acquireShared(_tracer, NODE, 2L);
            ClientC.acquireShared(_tracer, NODE, 3L);
            AcquireExclusive(ClientB, _tracer, NODE, 1L).callAndAssertWaiting();
            AcquireExclusive(ClientC, _tracer, NODE, 1L).callAndAssertWaiting();

            // When
            ClientC.stop();
            ClientB.stop();
            ClientA.stop();

            // All locks clients should be stopped at this point, and all all locks should be released because none of the
            // clients entered the prepare phase
            LockCountVisitor lockCountVisitor = new LockCountVisitor();

            Locks.accept(lockCountVisitor);
            assertEquals(0, lockCountVisitor.LockCount);
        }