@Test
  public void testAddBadLocator() {
    int port = 11011;
    InetSocketAddress fakeLocalHost1 = new InetSocketAddress("fakeLocalHost1", port);
    InetSocketAddress fakeLocalHost2 = new InetSocketAddress("fakeLocalHost2", port);
    List<HostAndPort> hostAndPortList = new ArrayList<>();
    hostAndPortList.add(new HostAndPort(fakeLocalHost1.getHostName(), fakeLocalHost1.getPort()));
    hostAndPortList.add(new HostAndPort(fakeLocalHost2.getHostName(), fakeLocalHost2.getPort()));
    AutoConnectionSourceImpl autoConnectionSource =
        new AutoConnectionSourceImpl(hostAndPortList, "", 60 * 1000, SocketFactory.DEFAULT);

    InetSocketAddress badLocator1 = new InetSocketAddress("fakeLocalHost1", port);
    InetSocketAddress badLocator2 = new InetSocketAddress("fakeLocalHost3", port);

    Set<HostAndPort> badLocators = new HashSet<>();
    badLocators.add(new HostAndPort(badLocator1.getHostName(), badLocator1.getPort()));
    badLocators.add(new HostAndPort(badLocator2.getHostName(), badLocator2.getPort()));

    autoConnectionSource.addBadLocators(hostAndPortList, badLocators);

    System.out.println("new locatores " + hostAndPortList);
    assertThat(hostAndPortList).hasSize(3);
  }
This test validates the AutoConnectionSourceImpl.addBadLocators method. That method adds
badLocator from badLocator list to new Locator list. And it make sure that new locator list
doesn't have similar entry. For that it checks hostname and port only.
geode-core/src/integrationTest/java/org/apache/geode/cache/client/internal/AutoConnectionSourceImplIntegrationTest.java