private static CacheServer addCacheServer() throws Exception {
    CacheServer s = cache.addCacheServer();
    int port = getRandomAvailableTCPPort();
    s.setPort(port);
    s.start();
    return s;
  }
This tests whether an exception is thrown in register/unregister when no server is available.
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/InterestListDUnitTest.java