//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTryUpgradeSharedToExclusive() public virtual void ShouldTryUpgradeSharedToExclusive() { // Given I've grabbed an exclusive lock assertTrue(ClientA.trySharedLock(NODE, 1L)); // Then I can upgrade it to exclusive assertTrue(ClientA.tryExclusiveLock(NODE, 1L)); // And other clients are denied it assertFalse(ClientB.trySharedLock(NODE, 1L)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldUpgradeExclusiveOnTry() public virtual void ShouldUpgradeExclusiveOnTry() { // Given I've grabbed a shared lock ClientA.acquireShared(LockTracer.NONE, NODE, 1L); // When assertTrue(ClientA.tryExclusiveLock(NODE, 1L)); // Then I should be able to release it ClientA.releaseExclusive(NODE, 1L); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldTryExclusiveLock() public virtual void ShouldTryExclusiveLock() { // Given I've grabbed an exclusive lock assertTrue(ClientA.tryExclusiveLock(NODE, 1L)); // Then other clients can't have exclusive locks assertFalse(ClientB.tryExclusiveLock(NODE, 1L)); // Nor can they have share locks assertFalse(ClientB.trySharedLock(NODE, 1L)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void exclusiveLocksShouldBeReentrantAndBlockOtherSharedLocks() public virtual void ExclusiveLocksShouldBeReentrantAndBlockOtherSharedLocks() { // When ClientA.acquireExclusive(LockTracer.NONE, NODE, 1L); ClientA.acquireShared(LockTracer.NONE, NODE, 1L); ClientA.tryExclusiveLock(NODE, 1L); // Then exclusive locks should wait Future <object> clientBLock = AcquireShared(ClientB, LockTracer.NONE, NODE, 1L).callAndAssertWaiting(); // And when ClientA.releaseExclusive(NODE, 1L); ClientA.releaseShared(NODE, 1L); // Then other thread should still wait AssertWaiting(ClientB, clientBLock); // But when ClientA.releaseExclusive(NODE, 1L); // Then AssertNotWaiting(ClientB, clientBLock); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test(expected = LockClientStoppedException.class) public void shouldNotBeAbleToTryAcquireExclusiveLockFromClosedClient() public virtual void ShouldNotBeAbleToTryAcquireExclusiveLockFromClosedClient() { ClientA.close(); ClientA.tryExclusiveLock(NODE, 1L); }