@Test
public void testRoundRobinBackoffInitialFailure() throws EventDeliveryException {

  Properties p = new Properties();
  List<LoadBalancedAvroHandler> hosts =
      new ArrayList<LoadBalancedAvroHandler>();
  List<Server> servers = new ArrayList<Server>();
  StringBuilder hostList = new StringBuilder("");
  for (int i = 0; i < 3; i++) {
    LoadBalancedAvroHandler s = new LoadBalancedAvroHandler();
    hosts.add(s);
    Server srv = RpcTestUtils.startServer(s);
    servers.add(srv);
    String name = "h" + i;
    p.put("hosts." + name, "127.0.0.1:" + srv.getPort());
    hostList.append(name).append(" ");
  }
  p.put("hosts", hostList.toString().trim());
  p.put("client.type", "default_loadbalance");
  p.put("host-selector", "round_robin");
  p.put("backoff", "true");
  RpcClient c = RpcClientFactory.getInstance(p);
  Assert.assertTrue(c instanceof LoadBalancingRpcClient);
  for (int i = 0; i < 3; i++) {
    c.append(EventBuilder.withBody("testing".getBytes()));
  }
  hosts.get(1).setFailed();
  for (int i = 0; i < 3; i++) {
    c.append(EventBuilder.withBody("testing".getBytes()));
  }
  hosts.get(1).setOK();
  //This time the iterators will never have "1".
  //So clients get in the order: 1 - 3 - 1
  for (int i = 0; i < 3; i++) {
    c.append(EventBuilder.withBody("testing".getBytes()));
  }
  Assert.assertEquals(1 + 2 + 1, hosts.get(0).getAppendCount());
  Assert.assertEquals(1, hosts.get(1).getAppendCount());
  Assert.assertEquals(1 + 1 + 2, hosts.get(2).getAppendCount());
}