@Test
public void getNextEqualWeight() throws Exception {

    LoadBalancedList<String> list = LoadBalancedLists.synchronizedList(new RoundRobinLoadBalancedList<String>());
    // add just one item
    list.set("Item1", 2);
    list.set("Item2", 2);
    list.set("Item3", 2);
    Assert.assertEquals("Item1", list.getNext());
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    Assert.assertEquals("Item1", list.getNext());
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    // k, now we repeat and every item is back in list of possible choices
    Assert.assertEquals("Item1", list.getNext());
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    // used up all of them once, item1 would normally have 1 more use left
    // let's reset its weight to 1 (which should remove it from possible list)
    list.set("Item1", 1);
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    Assert.assertEquals("Item1", list.getNext());
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    // reset weight of item1 back to two
    list.set("Item1", 2);
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    Assert.assertEquals("Item1", list.getNext());
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    Assert.assertEquals("Item1", list.getNext());
    Assert.assertEquals("Item2", list.getNext());
    Assert.assertEquals("Item3", list.getNext());
    // cycle should repeat now...
    Assert.assertEquals("Item1", list.getNext());
    Assert.assertEquals("Item2", list.getNext());
}