public static Integer createCacheServer() {
    CacheServer server1 = cache.addCacheServer();
    server1.setPort(0);
    try {
      server1.start();
    } catch (IOException e) {
      fail("Failed to start the Server", e);
    }
    assertThat(server1.isRunning()).isTrue();

    return server1.getPort();
  }
Method that creates a cache server

@return Integer Port on which the server is started.
geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java