@Test
  public void testSuspendLockingBlocksUntilNoLocks() throws InterruptedException {

    final String name = getUniqueName();
    distributedCreateService(2, name, true);
    final DistributedLockService service = getServiceNamed(name);

    // Get lock from other VM. Since same thread needs to lock and unlock,
    // invoke asynchronously, get lock, wait to be notified, then unlock.
    VM vm1 = getVM(1);
    AsyncInvocation<Void> asyncInvocation =
        vm1.invokeAsync(new SerializableRunnable("Lock & unlock in vm1") {
          @Override
          public void run() {
            DistributedLockService service2 = getServiceNamed(name);
            assertThat(service2.lock("lock", -1, -1)).isTrue();
            synchronized (monitor) {
              try {
                monitor.wait();
              } catch (InterruptedException ex) {
                out.println("Unexpected InterruptedException");
                fail("interrupted");
              }
            }
            service2.unlock("lock");
          }
        });
    // Let vm1's thread get the lock and go into wait()
    await().untilAsserted(() -> assertThat(asyncInvocation.isAlive()).isTrue());

    Thread thread = new Thread(() -> {
      setGot(service.suspendLocking(-1));
      setDone(true);
      service.resumeLocking();
    });
    setGot(false);
    setDone(false);
    thread.start();

    // Let thread start, make sure it's blocked in suspendLocking
    await().untilAsserted(() -> assertThat(thread.isAlive()).isTrue());
    assertThat(getGot() || getDone())
        .withFailMessage("Before release, got: " + getGot() + ", done: " + getDone()).isFalse();

    vm1.invoke(new SerializableRunnable("notify vm1 to unlock") {
      @Override
      public void run() {
        synchronized (monitor) {
          monitor.notify();
        }
      }
    });

    // Let thread finish, make sure it successfully suspended and is done
    WaitCriterion ev = new WaitCriterion() {
      @Override
      public boolean done() {
        return getDone();
      }

      @Override
      public String description() {
        return null;
      }
    };
    GeodeAwaitility.await().untilAsserted(ev);
    if (!getGot() || !getDone()) {
      dumpAllStacks();
    }
    assertThat(getGot() && getDone())
        .withFailMessage("After release, got: " + getGot() + ", done: " + getDone()).isTrue();

  }
Test that exlusive locking prohibits locking activity
geode-core/src/distributedTest/java/org/apache/geode/distributed/DistributedLockServiceDUnitTest.java