ProfiledReentrantReadWriteLock implements ReadWriteLock { @Override public ProfiledLock writeLock() { return writeLock; } ProfiledReentrantReadWriteLock(ReentrantReadWriteLock delegate, Ticker ticker, String label); @Override ProfiledLock readLock(); @Override ProfiledLock writeLock();  }
@Test public void lockingWriteLockOnlyLocksWriteLock() { ReentrantReadWriteLock delegate = new ReentrantReadWriteLock(); ProfiledReentrantReadWriteLock testSubject = new ProfiledReentrantReadWriteLock(delegate, Ticker.systemTicker(), LABEL); testSubject.writeLock().lock(); Assert.assertEquals(0, delegate.getReadHoldCount()); Assert.assertEquals(1, delegate.getWriteHoldCount()); }
@Test public void timeWaitingForWriteLockIsRecorded() { Ticker ticker = createMock(Ticker.class); ProfiledLock testSubject = new ProfiledReentrantReadWriteLock(new ReentrantReadWriteLock(), ticker, LABEL).writeLock(); timeWaitingForLockIsRecorded(testSubject, ticker); }
@Test public void timeWriteLockSpentLockedIsRecorded() { Ticker ticker = createMock(Ticker.class); ProfiledLock testSubject = new ProfiledReentrantReadWriteLock(new ReentrantReadWriteLock(), ticker, LABEL).writeLock(); timeSpentLockedIsRecorded(ticker, testSubject); }