public void testReadWriteDeadlocks() {
    
    // deadlock with three locks
    Object lock1 = new String("lock1");
    Object lock2 = new String("lock2");
    Object lock3 = new String("lock3");

    
    threads.add(new DeadlockingThreadReadWriteLock("t1", lock1, lock2));
    threads.add(new DeadlockingThreadReadWriteLock("t2", lock2, lock3));
    threads.add(new DeadlockingThreadReadWriteLock("t3", lock3, lock1));

    // deadlock with two locks
    Object lock4 = new String("lock4");
    Object lock5 = new String("lock5");

    threads.add(new DeadlockingThreadReadWriteLock("t4", lock4, lock5));
    threads.add(new DeadlockingThreadReadWriteLock("t5", lock5, lock4));
    DeadlockWarningThread wt = new DeadlockWarningThread(threads);

    

    while (true) {
      if(!wt.isAlive()) {
          break;
      }
    }
    if (wt.isDeadlocked()){
      Assert.assertTrue(wt.getErrorMessages().toString(), wt.isDeadlocked());
      Assert.assertFalse(wt.getErrorMessages().toString().equals(""));
    } else {
      Assert.assertTrue(wt.getErrorMessages().toString(), wt.isDeadlocked());
    }
    
  }
Test should detect "hidden" deadlock
This test commented because it is not testing any production code
In case if we change DeadlockWarningThread and need test of changes
we can add there @Test annotation
ambari-server/src/test/java/org/apache/ambari/server/testing/DeadlockedThreadsTest.java