Java源码示例:com.netflix.loadbalancer.ConfigurationBasedServerList

示例1
@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);
}
 
示例2
@Test
public void serverListOverridesToTest() {
	ConfigurationBasedServerList.class
			.cast(getLoadBalancer("localApp").getServerListImpl());
}