@Test
  public void testAreBalanced() {
    final LocatorLoadSnapshot sn = new LocatorLoadSnapshot();
    assertThat(sn.hasBalancedConnections(null)).isTrue();
    assertThat(sn.hasBalancedConnections("a")).isTrue();
    final ServerLocation l1 = new ServerLocation("localhost", 1);
    final ServerLocation l2 = new ServerLocation("localhost", 2);
    final ServerLocation l3 = new ServerLocation("localhost", 3);
    final String uniqueId1 = new InternalDistributedMember("localhost", 1).getUniqueId();
    final String uniqueId2 = new InternalDistributedMember("localhost", 2).getUniqueId();
    final String uniqueId3 = new InternalDistributedMember("localhost", 3).getUniqueId();
    sn.addServer(l1, uniqueId1, new String[] {"a"}, new ServerLoad(0, 1, 0, 1), LOAD_POLL_INTERVAL);
    sn.addServer(l2, uniqueId2, new String[] {"a", "b"}, new ServerLoad(0, 1, 0, 1),
        LOAD_POLL_INTERVAL);
    sn.addServer(l3, uniqueId3, new String[] {"b"}, new ServerLoad(0, 1, 0, 1), LOAD_POLL_INTERVAL);

    assertThat(sn.hasBalancedConnections(null)).isTrue();
    assertThat(sn.hasBalancedConnections("a")).isTrue();
    assertThat(sn.hasBalancedConnections("b")).isTrue();

    sn.updateLoad(l1, uniqueId1, new ServerLoad(1, 1, 0, 1));
    assertThat(sn.hasBalancedConnections(null)).isTrue();
    assertThat(sn.hasBalancedConnections("a")).isTrue();
    assertThat(sn.hasBalancedConnections("b")).isTrue();

    sn.updateLoad(l2, uniqueId2, new ServerLoad(2, 1, 0, 1));
    assertThat(sn.hasBalancedConnections(null)).isFalse();
    assertThat(sn.hasBalancedConnections("a")).isTrue();
    assertThat(sn.hasBalancedConnections("b")).isFalse();
  }
Test that we can specify a list of servers to exclude and the snapshot honors the request when
picking the best server.
geode-core/src/test/java/org/apache/geode/distributed/internal/LocatorLoadSnapshotTest.java