use of io.servicecomb.serviceregistry.api.registry.HealthCheckMode in project java-chassis by ServiceComb.
the class TestRegistry method testRegistryUtils.
@Test
public void testRegistryUtils() throws Exception {
Microservice oInstance = RegistryUtils.getMicroservice();
List<String> schemas = new ArrayList<>();
schemas.add("testSchema");
oInstance.setSchemas(schemas);
oInstance.setServiceId("testServiceId");
oInstance.setStatus(MicroserviceStatus.UNKNOWN.name());
Map<String, String> properties = new HashMap<>();
properties.put("proxy", "testPorxy");
oInstance.setProperties(properties);
Assert.assertEquals("default", oInstance.getServiceName());
Assert.assertEquals("default", oInstance.getAppId());
Assert.assertEquals("", oInstance.getDescription());
Assert.assertEquals("FRONT", oInstance.getLevel());
Assert.assertEquals("testPorxy", oInstance.getProperties().get("proxy"));
Assert.assertEquals("testServiceId", oInstance.getServiceId());
Assert.assertEquals("0.0.1", oInstance.getVersion());
Assert.assertEquals(1, oInstance.getSchemas().size());
Assert.assertEquals(MicroserviceStatus.UNKNOWN.name(), oInstance.getStatus());
RegistryUtils.getMicroserviceInstance().setHostName("test");
RegistryUtils.getMicroserviceInstance().setServiceId("testServiceID");
RegistryUtils.getMicroserviceInstance().setInstanceId("testID");
RegistryUtils.getMicroserviceInstance().setStage("testStage");
List<String> endpoints = new ArrayList<>();
endpoints.add("localhost");
RegistryUtils.getMicroserviceInstance().setEndpoints(endpoints);
RegistryUtils.getMicroserviceInstance().setStatus(MicroserviceInstanceStatus.STARTING);
RegistryUtils.getMicroserviceInstance().setProperties(properties);
HealthCheck oHealthCheck = new HealthCheck();
oHealthCheck.setInterval(10);
oHealthCheck.setPort(8080);
oHealthCheck.setTimes(20);
HealthCheckMode oHealthCheckMode = HealthCheckMode.PLATFORM;
oHealthCheck.setMode(oHealthCheckMode);
RegistryUtils.getMicroserviceInstance().setHealthCheck(oHealthCheck);
Assert.assertEquals("test", RegistryUtils.getMicroserviceInstance().getHostName());
Assert.assertEquals("testServiceID", RegistryUtils.getMicroserviceInstance().getServiceId());
Assert.assertEquals("testID", RegistryUtils.getMicroserviceInstance().getInstanceId());
Assert.assertEquals(endpoints, RegistryUtils.getMicroserviceInstance().getEndpoints());
Assert.assertEquals(MicroserviceInstanceStatus.STARTING, RegistryUtils.getMicroserviceInstance().getStatus());
Assert.assertEquals(10, RegistryUtils.getMicroserviceInstance().getHealthCheck().getInterval());
Assert.assertEquals(8080, RegistryUtils.getMicroserviceInstance().getHealthCheck().getPort());
Assert.assertEquals(20, RegistryUtils.getMicroserviceInstance().getHealthCheck().getTimes());
Assert.assertEquals("pull", RegistryUtils.getMicroserviceInstance().getHealthCheck().getMode().getName());
Assert.assertEquals(0, RegistryUtils.getMicroserviceInstance().getHealthCheck().getTTL());
RegistryUtils.getMicroserviceInstance().getHealthCheck().setMode(HealthCheckMode.HEARTBEAT);
Assert.assertNotEquals(0, RegistryUtils.getMicroserviceInstance().getHealthCheck().getTTL());
Assert.assertEquals("testPorxy", RegistryUtils.getMicroserviceInstance().getProperties().get("proxy"));
Assert.assertEquals("testStage", RegistryUtils.getMicroserviceInstance().getStage());
}
Aggregations