Search in sources :

Example 1 with ConfigurationBasedServerList

use of com.netflix.loadbalancer.ConfigurationBasedServerList in project ribbon by Netflix.

the class ClientFactoryTest method testChooseServers.

@Test
public void testChooseServers() {
    assertNotNull(client);
    DynamicServerListLoadBalancer lb = (DynamicServerListLoadBalancer) client.getLoadBalancer();
    assertTrue(lb.getServerListImpl() instanceof ConfigurationBasedServerList);
    Set<Server> expected = new HashSet<Server>();
    expected.add(new Server("www.example1.come:80"));
    expected.add(new Server("www.example2.come:80"));
    expected.add(new Server("www.example3.come:80"));
    Set<Server> result = new HashSet<Server>();
    for (int i = 0; i <= 10; i++) {
        Server s = lb.chooseServer();
        result.add(s);
    }
    assertEquals(expected, result);
}
Also used : Server(com.netflix.loadbalancer.Server) ConfigurationBasedServerList(com.netflix.loadbalancer.ConfigurationBasedServerList) DynamicServerListLoadBalancer(com.netflix.loadbalancer.DynamicServerListLoadBalancer) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ConfigurationBasedServerList (com.netflix.loadbalancer.ConfigurationBasedServerList)1 DynamicServerListLoadBalancer (com.netflix.loadbalancer.DynamicServerListLoadBalancer)1 Server (com.netflix.loadbalancer.Server)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1