### Question:
LockManager { int getLockTableRefCountFor(final DN dn) { final int dnHashCode = dn.hashCode(); final LinkedList<DNLockHolder> bucket = getBucket(dnHashCode); synchronized (bucket) { for (final DNLockHolder lock : bucket) { if (lock.dnHashCode == dnHashCode && lock.dn.equals(dn)) { return lock.refCount.get(); } } return -1; } } LockManager();  LockManager(final long lockTimeout, final TimeUnit lockTimeoutUnit); @SuppressWarnings("unchecked")  LockManager(final long lockTimeout, final TimeUnit lockTimeoutUnit, final int numberOfBuckets); @Override String toString(); DNLock tryReadLockEntry(final DN entry); DNLock tryWriteLockEntry(final DN entry); DNLock tryWriteLockSubtree(final DN subtree);  }### Answer:
@Test(dataProvider = "multiThreadedLockCombinationsWhichShouldBlock") public void testMultiThreadedLockCombinationsWhichShouldBlock(final LockType lock1Type, final DN dn1, final LockType lock2Type, final DN dn2) throws Exception { final LockManager lockManager = new LockManager(); final DNLock lock1 = lockUsingThread(thread1, lockManager, lock1Type, dn1).get(); final Future<DNLock> lock2Future = lockUsingThread(thread2, lockManager, lock2Type, dn2); try { lock2Future.get(10, TimeUnit.MILLISECONDS); } catch (final TimeoutException e) { } assertThat(lock2Future.isDone()).isFalse(); unlockUsingThread(thread1, lock1); final DNLock lock2 = lock2Future.get(); unlockUsingThread(thread2, lock2); assertThat(getThreadLocalLockRefCountFor(thread1, lockManager, dn1)).isGreaterThan(0); assertThat(getThreadLocalLockRefCountFor(thread2, lockManager, dn2)).isGreaterThan(0); assertThat(lockManager.getLockTableRefCountFor(dn1)).isGreaterThan(0); assertThat(lockManager.getLockTableRefCountFor(dn2)).isGreaterThan(0); }
@Test(dataProvider = "multiThreadedLockCombinationsWhichShouldNotBlock") public void testMultiThreadedLockCombinationsWhichShouldNotBlock(final LockType lock1Type, final DN dn1, final LockType lock2Type, final DN dn2) throws Exception { final LockManager lockManager = new LockManager(); final DNLock lock1 = lockUsingThread(thread1, lockManager, lock1Type, dn1).get(); final DNLock lock2 = lockUsingThread(thread2, lockManager, lock2Type, dn2).get(); assertThat(lock1).isNotSameAs(lock2); unlockUsingThread(thread1, lock1); unlockUsingThread(thread2, lock2); assertThat(getThreadLocalLockRefCountFor(thread1, lockManager, dn1)).isGreaterThan(0); assertThat(getThreadLocalLockRefCountFor(thread2, lockManager, dn2)).isGreaterThan(0); assertThat(lockManager.getLockTableRefCountFor(dn1)).isGreaterThan(0); assertThat(lockManager.getLockTableRefCountFor(dn2)).isGreaterThan(0); }