private static void loadBalancer(XmlGenerator gen, LoadBalancer loadBalancer) {
        if (loadBalancer == null) {
            return;
        }
        String type;
        if (loadBalancer instanceof RandomLB) {
            type = "random";
        } else if (loadBalancer instanceof RoundRobinLB) {
            type = "round-robin";
        } else {
            type = "custom";
        }

        if ("custom".equals(type)) {
            gen.node("load-balancer", loadBalancer.getClass().getName(), "type", type);
        } else {
            gen.node("load-balancer", null, "type", type);
        }
    }
@Test
    public void loadBalancer() {
        clientConfig.setLoadBalancer(new RandomLB());
        ClientConfig newClientConfig = newConfigViaGenerator();
        LoadBalancer actual = newClientConfig.getLoadBalancer();
        assertTrue(actual instanceof RandomLB);
        String actualClassName = newClientConfig.getLoadBalancerClassName();
        assertNull(actualClassName);
    }