ReentrantReadWriteUpdateLock implements ReadWriteUpdateLock { @Override public Lock readLock() { return readLock; }  @Override Lock updateLock(); @Override Lock readLock(); @Override Lock writeLock();  }
@Test public void testReadLockHoldCount() throws Exception { reentrantReadWriteUpdateLock.readLock().lock(); int hc1 = ((ReentrantReadWriteUpdateLock.ReadLock)reentrantReadWriteUpdateLock.readLock()).holdCount().value; reentrantReadWriteUpdateLock.readLock().unlock(); int hc2 = ((ReentrantReadWriteUpdateLock.ReadLock)reentrantReadWriteUpdateLock.readLock()).holdCount().value; assertEquals(1, hc1); assertEquals(0, hc2); }
@Test public void testReadLockHoldCount_Interruptibly() throws Exception { reentrantReadWriteUpdateLock.readLock().lockInterruptibly(); int hc1 = ((ReentrantReadWriteUpdateLock.ReadLock)reentrantReadWriteUpdateLock.readLock()).holdCount().value; reentrantReadWriteUpdateLock.readLock().unlock(); int hc2 = ((ReentrantReadWriteUpdateLock.ReadLock)reentrantReadWriteUpdateLock.readLock()).holdCount().value; assertEquals(1, hc1); assertEquals(0, hc2); }
@Test(expected = UnsupportedOperationException.class) public void testReadLockNewCondition() throws Exception { reentrantReadWriteUpdateLock.readLock().newCondition(); }