@Test
  public void testNumOfServersDUnitTest() throws Exception {
    initManagement(false);
    VM server = managedNodeList.get(1);
    int serverPort = AvailablePortHelper.getRandomAvailableTCPPort();
    cqDUnitTest.createServer(server, serverPort);
    int serverCount =
        ((Number) managingNode.invoke(TestServerDUnitTest::getNumOfServersFromMBean))
            .intValue();
    LogWriterUtils.getLogWriter().info("TestServerDUnitTest serverCount =" + serverCount);
    cqDUnitTest.closeServer(server);
    assertEquals(1, serverCount);
  }
This is for testing server count details from MBean
geode-cq/src/distributedTest/java/org/apache/geode/management/internal/pulse/TestServerDUnitTest.java