@Test
  public void testCleanUp() {
    TransactionManager tm1 = null;
    TransactionManager tm2 = null;
    try {
      props = new Properties();
      props.setProperty(MCAST_PORT, "0");
      String path =
          createTempFileFromResource(RestartJUnitTest.class, "/jta/cachejta.xml")
              .getAbsolutePath();
      props.setProperty(CACHE_XML_FILE, path);

      ds1 = DistributedSystem.connect(props);
      cache = CacheFactory.create(ds1);
      tm1 = JNDIInvoker.getTransactionManager();
      cache.close();
      ds1.disconnect();

      ds1 = DistributedSystem.connect(props);
      cache = CacheFactory.create(ds1);
      tm2 = JNDIInvoker.getTransactionManager();
      assertNotSame("TransactionManager are same in before restart and after restart", tm1, tm2);

      ds1.disconnect();
    } catch (Exception e) {
      fail("Failed in restarting the distributed system");
    }
  }
This test check the graceful removal of all the resource (DataSources , TransactionManager and
UserTransaction and its associated thread) before we reconnect to the distributed syatem.
geode-core/src/integrationTest/java/org/apache/geode/internal/datasource/RestartJUnitTest.java