@Test
  public void testLockAlreadyTakenElsewhere() throws InterruptedException {
    DistributedLockService dls = new GeodeCacheFacade(cache).getDLS();
    assertTrue(dls.lock(AutoBalancer.AUTO_BALANCER_LOCK, 0, -1));

    final AtomicBoolean success = new AtomicBoolean(true);

    Thread thread = new Thread(() -> {
      CacheOperationFacade cacheFacade = new GeodeCacheFacade(cache);
      success.set(cacheFacade.acquireAutoBalanceLock());
    });
    thread.start();
    thread.join();

    assertFalse(success.get());
  }
IntegrationTests for AutoBalancer that include usage of Cache, StatSampler and
DistributedLockService.
geode-rebalancer/src/integrationTest/java/org/apache/geode/cache/util/AutoBalancerIntegrationJUnitTest.java