@Test
  public void testTwoLocatorsTwoServers() {
    String locators = hostName + "[" + port1 + "]," + hostName + "[" + port2 + "]";

    Properties dsProps = getBasicProperties(locators);
    addDSProps(dsProps);

    startLocator(vm0, dsProps, port1);

    startLocator(vm3, dsProps, port2);

    SerializableRunnable connect = new SerializableRunnable("Connect to " + locators) {
      @Override
      public void run() {
        Properties props = getBasicProperties(locators);
        addDSProps(props);
        getConnectedDistributedSystem(props);
      }
    };
    vm1.invoke(connect);
    vm2.invoke(connect);

    Properties props = getBasicProperties(locators);

    addDSProps(props);
    system = getConnectedDistributedSystem(props);

    await().until(() -> system.getDM().getViewMembers().size() >= 3);

    // three applications plus
    assertThat(system.getDM().getViewMembers().size()).isEqualTo(5);
  }
Tests starting two locators and two servers in different JVMs
geode-core/src/distributedTest/java/org/apache/geode/distributed/LocatorDUnitTest.java