use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestPropertiesLoader method testMicroservicePropertiesLoader.
@Test
public void testMicroservicePropertiesLoader() throws Exception {
Microservice microservice = LocalServiceRegistryFactory.createLocal().getMicroservice();
Map<String, String> expectedMap = new HashMap<>();
expectedMap.put("key1", "value1");
expectedMap.put("key2", "value2");
expectedMap.put("ek0", "ev0");
Assert.assertEquals(expectedMap, microservice.getProperties());
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestPropertiesLoader method testEmptyExtendedClass.
@Test
public void testEmptyExtendedClass() {
Configuration configuration = ConfigUtil.createLocalConfig();
configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_NAME, "emptyExtendedClass");
configuration.clearProperty(BootStrapProperties.CONFIG_SERVICE_PROPERTIES);
configuration.clearProperty(BootStrapProperties.OLD_CONFIG_SERVICE_PROPERTIES);
Microservice microservice = microserviceFactory.create(configuration);
// microservice.yaml has 3 properties
Assert.assertEquals(3, microservice.getProperties().size());
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestPropertiesLoader method testInstancePropertiesLoader.
@Test
public void testInstancePropertiesLoader() {
Microservice microservice = LocalServiceRegistryFactory.createLocal().getMicroservice();
MicroserviceInstance instance = microservice.getInstance();
Map<String, String> expectedMap = new HashMap<>();
expectedMap.put("key0", "value0");
expectedMap.put("ek0", "ev0");
Assert.assertEquals(expectedMap, instance.getProperties());
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestInstanceCacheCheckerMock method registerMicroservice.
private void registerMicroservice(String appId, String microserviceName) {
Microservice microservice = new Microservice();
microservice.setAppId(appId);
microservice.setServiceName(microserviceName);
microservice.setVersion("1.0.0");
serviceRegistry.getServiceRegistryClient().registerMicroservice(microservice);
}
use of org.apache.servicecomb.registry.api.registry.Microservice in project java-chassis by ServiceComb.
the class TestAbstractRegisterTask method testHeartbeatOtherFailed.
@Test
public void testHeartbeatOtherFailed(@Mocked ServiceRegistryClient srClient) {
MicroserviceRegisterTask registerTask = new MicroserviceRegisterTask(eventBus, srClient, microservice);
ReflectUtils.setField(registerTask, "registered", true);
Microservice otherMicroservice = new Microservice();
otherMicroservice.setAppId(microservice.getAppId());
otherMicroservice.setServiceName("ms1");
MicroserviceInstanceHeartbeatTask heartbeatTask = new MicroserviceInstanceHeartbeatTask(eventBus, srClient, otherMicroservice);
ReflectUtils.setField(heartbeatTask, "heartbeatResult", HeartbeatResult.INSTANCE_NOT_REGISTERED);
Assert.assertEquals(true, registerTask.isRegistered());
eventBus.post(heartbeatTask);
Assert.assertEquals(true, registerTask.isRegistered());
}
Aggregations