use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project java-chassis by ServiceComb.
the class TestMicroserviceFactory method testCreateMicroserviceFromDefinitionWithInvalidVersion.
@Test
public void testCreateMicroserviceFromDefinitionWithInvalidVersion() {
Configuration configuration = ConfigUtil.createLocalConfig();
configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_VERSION, "x.y.x.1");
expectedException.equals(IllegalStateException.class);
expectedException.expectMessage("Invalid major \"x\", version \"x.y.x.1\".");
MicroserviceFactory microserviceFactory = new MicroserviceFactory();
microserviceFactory.create(configuration);
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project java-chassis by ServiceComb.
the class TestMicroserviceFactory method testSetDescription.
@Test
public void testSetDescription() {
MicroserviceFactory factory = new MicroserviceFactory();
Configuration configuration = ConfigUtil.createLocalConfig();
configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_DESCRIPTION, new String[] { "test1", "test2" });
Microservice microservice = factory.create(configuration);
Assert.assertEquals("test1,test2", microservice.getDescription());
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project java-chassis by ServiceComb.
the class TestMicroserviceFactory method testSetDescriptionOnBlankDescription.
@Test
public void testSetDescriptionOnBlankDescription() {
Configuration configuration = ConfigUtil.createLocalConfig();
configuration.setProperty(BootStrapProperties.CONFIG_SERVICE_DESCRIPTION, new String[] { " ", " " });
MicroserviceFactory factory = new MicroserviceFactory();
Microservice microservice = factory.create(configuration);
Assert.assertEquals(" , ", microservice.getDescription());
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project java-chassis by ServiceComb.
the class LocalRegistryStore method init.
public void init() {
MicroserviceFactory microserviceFactory = new MicroserviceFactory();
selfMicroservice = microserviceFactory.create();
selfMicroserviceInstance = selfMicroservice.getInstance();
microserviceMap.clear();
microserviceInstanceMap.clear();
}
use of org.apache.servicecomb.registry.api.registry.MicroserviceFactory in project java-chassis by ServiceComb.
the class TestServiceRegistryClientImpl method testException.
@Test
public void testException() {
ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_APPLICATION, "app");
ArchaiusUtils.setProperty(BootStrapProperties.CONFIG_SERVICE_NAME, "ms");
MicroserviceFactory microserviceFactory = new MicroserviceFactory();
Microservice microservice = microserviceFactory.create();
Assert.assertNull(oClient.registerMicroservice(microservice));
Assert.assertNull(oClient.registerMicroserviceInstance(microservice.getInstance()));
oClient.init();
Assert.assertNull(oClient.getMicroserviceId(microservice.getAppId(), microservice.getServiceName(), microservice.getVersion(), microservice.getEnvironment()));
Assert.assertThat(oClient.getAllMicroservices().isEmpty(), is(true));
Assert.assertNull(oClient.registerMicroservice(microservice));
Assert.assertNull(oClient.getMicroservice("microserviceId"));
Assert.assertNull(oClient.getMicroserviceInstance("consumerId", "providerId"));
Assert.assertFalse(oClient.unregisterMicroserviceInstance("microserviceId", "microserviceInstanceId"));
Assert.assertNull(oClient.heartbeat("microserviceId", "microserviceInstanceId"));
Assert.assertNull(oClient.findServiceInstance("selfMicroserviceId", "appId", "serviceName", "versionRule"));
Assert.assertNull(oClient.findServiceInstances("selfMicroserviceId", "appId", "serviceName", "versionRule", "0"));
Assert.assertEquals("a", new ClientException("a").getMessage());
ArchaiusUtils.resetConfig();
}
Aggregations