@Test
  public void testTryResumeRemoveItselfFromWaitingQueue() throws Exception {
    int time = 30;
    long timeout = TimeUnit.SECONDS.toNanos(time);
    TXManagerImpl txMgr = (TXManagerImpl) cache.getCacheTransactionManager();
    TXManagerImpl spyMgr = spy(txMgr);
    doAnswer((Answer<Void>) invocation -> {
      Thread.sleep(10);
      return null;
    }).when(spyMgr).parkToRetryResume(timeout);
    spyMgr.begin();
    region.put("key", "value");
    final TransactionId txId = spyMgr.suspend();
    spyMgr.resume(txId);
    final CountDownLatch latch1 = new CountDownLatch(2);
    final CountDownLatch latch2 = new CountDownLatch(2);
    Thread t1 = new Thread(() -> {
      latch1.countDown();
      assertTrue(spyMgr.tryResume(txId, time, TimeUnit.SECONDS));
      region.put("key1", "value1");
      assertEquals(txId, spyMgr.suspend());
      latch2.countDown();
    });
    Thread t2 = new Thread(() -> {
      latch1.countDown();
      assertTrue(spyMgr.tryResume(txId, time, TimeUnit.SECONDS));
      region.put("key2", "value1");
      assertEquals(txId, spyMgr.suspend());
      latch2.countDown();
    });
    t1.start();
    t2.start();
    Thread.sleep(300);
    if (!latch1.await(30, TimeUnit.SECONDS)) {
      fail("junit test failed");
    }
    spyMgr.suspend();
    if (!latch2.await(30, TimeUnit.SECONDS)) {
      fail("junit test failed");
    }
    spyMgr.tryResume(txId, time, TimeUnit.SECONDS);
    assertEquals(3, region.size());
    assertEquals(0, spyMgr.getWaitQueue(txId).size());
    spyMgr.commit();
  }
test that timeout of Long.MAX_VALUE does not return immediately
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/TXManagerImplJUnitTest.java