### Question:
ConfigServerList implements ServerList { public ConfigServerList(String serviceName) { Preconditions.checkArgument(!Strings.isNullOrEmpty(serviceName), "'serviceName' cannot be blank."); this.serviceName = serviceName; final String propertyName = PROPERTY_NAME_PREFIX + "." + serviceName; propServers = DynamicPropertyFactory.getInstance().getStringProperty(propertyName, null); if (propServers == null) { logger.warn("No configuration property found with name {}. To enable load balancing using {}, add this property with your target server instances.", propertyName, ConfigServerList.class.getName()); return; } propServers.addCallback(new Runnable() { @Override public void run() { convertPropertyToList(); } }); convertPropertyToList(); } ConfigServerList(String serviceName); @Override String getServiceName(); @Override List<ServerInstance> getListOfServers(); final static String PROPERTY_NAME_PREFIX; }### Answer:
@Test public void configServerListTest() throws InterruptedException { ConfigurationManager.getConfigInstance().setProperty("janus.listOfServers."+VIP, "http: ConfigServerList serverList = new ConfigServerList(VIP); List<ServerInstance> servers = serverList.getListOfServers(); ServerInstance server = servers.get(0); Assert.assertEquals(server.getId(), "localhost:8080"); Assert.assertEquals( server.getHost(), "localhost"); Assert.assertEquals( server.getPort(), 8080); server = servers.get(1); Assert.assertEquals( server.getId(), "localhost:8180"); Assert.assertEquals(server.getHost(), "localhost"); Assert.assertEquals(server.getPort(), 8180); Assert.assertEquals( VIP, serverList.getServiceName() ); }