public void startServer() {
    if (servers == null) {
      servers = new ArrayList<>();
    }
    CacheFactory cf = new CacheFactory(properties);
    if (pdxPersistentUserSet) {
      cf.setPdxPersistent(pdxPersistent);
    }
    if (pdxReadSerializedUserSet) {
      cf.setPdxReadSerialized(pdxReadSerialized);
    }
    if (pdxSerializer != null) {
      cf.setPdxSerializer(pdxSerializer);
    }
    cache = (InternalCache) cf.create();
    DistributionConfig config =
        ((InternalDistributedSystem) cache.getDistributedSystem()).getConfig();
    jmxPort = config.getJmxManagerPort();
    httpPort = config.getHttpServicePort();

    for (int i = 0; i < serverCount; i++) {
      CacheServer server = cache.addCacheServer();
      if (i == 0) {
        CacheServerHelper.setIsDefaultServer(server);
      }
      // memberPort is by default zero, which translates to "randomly select an available port,"
      // which is why it is updated after this try block
      if (serverCount == 1) {
        server.setPort(memberPort);
      } else {
        server.setPort(0);
      }
      if (maxThreads >= 0) {
        server.setMaxThreads(maxThreads);
      }
      try {
        server.start();
      } catch (IOException e) {
        throw new RuntimeException("unable to start server", e);
      }
      // if this member has multiple cache servers, the memberPort will be the last server's port
      // started.
      memberPort = server.getPort();
      servers.add(server);
    }
  }
This is a rule to start up a server in your current VM. It's useful for your Integration Tests.

<p>
This rules allows you to create/start a server using any @ConfigurationProperties, you can chain
the configuration of the rule like this: ServerStarterRule server = new ServerStarterRule()
.withProperty(key, value) .withName(name) .withProperties(properties) .withSecurityManager(class)
.withJmxManager() .withRestService() .withEmbeddedLocator() .withRegion(type, name) etc, etc. If
your rule calls withAutoStart(), the cache and server will be started before your test code.

<p>
In your test code, you can use the rule to access the server's attributes, like the port
information, working dir, name, and the cache and cacheServer it creates.

<p>
If you need a rule to start a server/locator in different VMs for Distributed tests, You should
use {@code ClusterStartupRule}.
geode-dunit/src/main/java/org/apache/geode/test/junit/rules/ServerStarterRule.java