@Override
    public ServiceInstance doChoose(String serviceName, List<ServiceInstance> instances) {
        final int index = Math.abs(position.incrementAndGet());
        return instances.get(index % instances.size());
    }
@Test
    public void doChoose() {
        int port1 = 9999;
        int port2 = 8888;
        String serviceName = "round";
        final List<ServiceInstance> serviceInstances = Arrays
                .asList(CommonUtils.buildInstance(serviceName, port1), CommonUtils.buildInstance(serviceName, port2));
        final RoundRobinLoadbalancer roundRobinLoadbalancer = new RoundRobinLoadbalancer();
        // The simulation is invoked twice, once selected for each instance
        int count = 2;
        for (int i = 0; i < count; i++) {
            final Optional<ServiceInstance> choose = roundRobinLoadbalancer.choose(serviceName, serviceInstances);
            Assert.assertTrue(choose.isPresent());
            if (port1 == choose.get().getPort()) {
                port1--;
            }
            if (port2 == choose.get().getPort()) {
                port2--;
            }
        }
        Assert.assertTrue(port1 == 9998 && port2 == 8887);
    }