@Override
  protected void createCacheManagers() throws Throwable {
    ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false);
    addClusterEnabledCacheManager(builder);
    addClusterEnabledCacheManager(builder);

    hotRodServer1 = TestHelper.startHotRodServer(manager(0));
    hotRodServer2 = TestHelper.startHotRodServer(manager(1));

    assert manager(0).getCache() != null;
    assert manager(1).getCache() != null;

    waitForClusterToForm();

    cache(0).put("k", "v");
    assertEquals("v", cache(1).get("k"));
  }
  @Override
  protected void createCacheManagers() throws Throwable {
    c1 = TestCacheManagerFactory.createLocalCacheManager(false).getCache();
    c2 = TestCacheManagerFactory.createLocalCacheManager(false).getCache();
    c3 = TestCacheManagerFactory.createLocalCacheManager(false).getCache();
    registerCacheManager(c1.getCacheManager(), c2.getCacheManager(), c3.getCacheManager());

    hotRodServer1 = TestHelper.startHotRodServer(c1.getCacheManager());
    hotRodServer2 = TestHelper.startHotRodServer(c2.getCacheManager());
    hotRodServer3 = TestHelper.startHotRodServer(c3.getCacheManager());

    log.trace("Server 1 port: " + hotRodServer1.getPort());
    log.trace("Server 2 port: " + hotRodServer2.getPort());
    log.trace("Server 3 port: " + hotRodServer3.getPort());
    String servers = TestHelper.getServersString(hotRodServer1, hotRodServer2, hotRodServer3);
    log.trace("Server list is: " + servers);
    RemoteCacheManager remoteCacheManager = new RemoteCacheManager(servers);
    remoteCache = remoteCacheManager.getCache();
  }
  @Override
  protected EmbeddedCacheManager createCacheManager() throws Exception {
    latch = new CountDownLatch(1);
    cacheManager =
        new HangingCacheManager(
            TestCacheManagerFactory.createCacheManager(hotRodCacheConfiguration()), latch);
    // cacheManager = TestCacheManagerFactory.createLocalCacheManager();
    // pass the config file to the cache
    hotrodServer = TestHelper.startHotRodServer(cacheManager);
    log.info("Started server on port: " + hotrodServer.getPort());

    remoteCacheManager = getRemoteCacheManager();
    defaultRemote = remoteCacheManager.getCache();

    return cacheManager;
  }
  @Override
  protected void createCacheManagers() throws Throwable {
    final int numServers = numberOfHotRodServers();
    hotrodServers = new HotRodServer[numServers];

    createCluster(clusterConfig(), numberOfHotRodServers());

    for (int i = 0; i < numServers; i++) {
      EmbeddedCacheManager cm = cacheManagers.get(i);
      hotrodServers[i] = TestHelper.startHotRodServer(cm);
    }

    String servers = TestHelper.getServersString(hotrodServers);

    remoteCacheManager = new RemoteCacheManager(servers);
    remoteCache = remoteCacheManager.getCache();
  };
  @Test(dependsOnMethods = "testRoundRobinLoadBalancing")
  public void testAddNewHotrodServer() {
    c4 = TestCacheManagerFactory.createLocalCacheManager(false).getCache();
    hotRodServer4 = TestHelper.startHotRodServer((EmbeddedCacheManager) c4.getCacheManager());
    registerCacheManager(c4.getCacheManager());

    List<SocketAddress> serverAddresses = new ArrayList<SocketAddress>();
    serverAddresses.add(new InetSocketAddress("localhost", hotRodServer1.getPort()));
    serverAddresses.add(new InetSocketAddress("localhost", hotRodServer2.getPort()));
    serverAddresses.add(new InetSocketAddress("localhost", hotRodServer3.getPort()));
    serverAddresses.add(new InetSocketAddress("localhost", hotRodServer4.getPort()));

    RoundRobinBalancingStrategy balancer = getBalancer();
    balancer.setServers(serverAddresses);

    remoteCache.put("k1", "v1");
    remoteCache.put("k2", "v2");
    remoteCache.put("k3", "v3");
    remoteCache.put("k4", "v4");

    assertEquals(1, c1.size());
    assertEquals(1, c2.size());
    assertEquals(1, c3.size());
    assertEquals(1, c4.size());

    assertEquals("v1", remoteCache.get("k1"));
    assertEquals("v2", remoteCache.get("k2"));
    assertEquals("v3", remoteCache.get("k3"));
    assertEquals("v4", remoteCache.get("k4"));

    remoteCache.put("k5", "v2");
    remoteCache.put("k6", "v3");
    remoteCache.put("k7", "v1");
    remoteCache.put("k8", "v2");
    remoteCache.put("k9", "v3");
    remoteCache.put("k10", "v3");
    remoteCache.put("k11", "v3");
    remoteCache.put("k12", "v3");

    assertEquals(3, c1.size());
    assertEquals(3, c2.size());
    assertEquals(3, c3.size());
    assertEquals(3, c4.size());
  }