private int createServerCache() throws IOException {
    Cache cache = managementTestRule.getCache();

    AttributesFactory factory = new AttributesFactory();
    factory.setScope(Scope.DISTRIBUTED_ACK);
    factory.setDataPolicy(DataPolicy.REPLICATE);

    RegionAttributes attrs = factory.create();
    cache.createRegion(REGION_NAME, attrs);

    CacheServer cacheServer = cache.addCacheServer();
    cacheServer.setPort(0);
    cacheServer.setNotifyBySubscription(true);
    cacheServer.start();
    return cacheServer.getPort();
  }
This is for testing client IDs
geode-core/src/distributedTest/java/org/apache/geode/management/internal/pulse/TestClientIdsDUnitTest.java