@Test
public void createsProfiledReadWriteLockIfProfilingIsEnabled() {

  Configuration config = createNiceMock(Configuration.class);
  expect(config.isServerLocksProfilingEnabled()).andReturn(true);
  replayAll();
  LockFactory factory = new LockFactory(config);
  ReadWriteLock lock = factory.newReadWriteLock();
  Assert.assertTrue(lock instanceof ProfiledReentrantReadWriteLock);
  String readLockLabel = ((ProfiledReentrantReadWriteLock) lock).readLock().getLabel();
  Assert.assertTrue(readLockLabel, readLockLabel.contains("LockFactoryTest.java"));
  String writeLockLabel = ((ProfiledReentrantReadWriteLock) lock).writeLock().getLabel();
  Assert.assertTrue(writeLockLabel, writeLockLabel.contains("LockFactoryTest.java"));
  verifyAll();
}