use of org.springframework.cloud.consul.discovery.ConsulServerList in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedInstanceGroupTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService1-WithGroup");
assertNotNull("service was null", service);
assertNotEquals("service port is 0", 0, service.getPort().intValue());
assertEquals("service id was wrong", "myTestService1-WithGroup", service.getId());
assertTrue("service group was wrong", service.getTags().contains("group=test"));
ConsulServerList serverList = new ConsulServerList(consul, properties);
DefaultClientConfigImpl config = new DefaultClientConfigImpl();
config.setClientName("myTestService-WithGroup");
serverList.initWithNiwsConfig(config);
List<ConsulServer> servers = serverList.getInitialListOfServers();
assertEquals("servers was wrong size", 1, servers.size());
assertEquals("service group was wrong", "test", servers.get(0).getMetaInfo().getServerGroup());
}
Aggregations