use of org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition in project incubator-servicecomb-java-chassis by apache.
the class RegistryUtils method init.
public static void init() {
MicroserviceConfigLoader loader = ConfigUtil.getMicroserviceConfigLoader();
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
serviceRegistry = ServiceRegistryFactory.getOrCreate(EventManager.eventBus, ServiceRegistryConfig.INSTANCE, microserviceDefinition);
serviceRegistry.init();
}
use of org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition in project incubator-servicecomb-java-chassis by apache.
the class TestPropertiesLoader method testCanNotAssignExtendedClass.
@Test
public void testCanNotAssignExtendedClass() {
ConfigModel configModel = MicroserviceDefinition.createConfigModel("default", "invalidExtendedClass");
@SuppressWarnings("unchecked") Map<String, Object> desc = (Map<String, Object>) configModel.getConfig().get(CONFIG_SERVICE_DESCRIPTION_KEY);
desc.put("propertyExtentedClass", "java.lang.String");
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(Arrays.asList(configModel));
try {
microserviceFactory.create(microserviceDefinition);
Assert.fail("Must throw exception");
} catch (Error e) {
Assert.assertEquals("Define propertyExtendedClass java.lang.String in yaml, but not implement the interface PropertyExtended.", e.getMessage());
}
}
use of org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition in project incubator-servicecomb-java-chassis by apache.
the class TestMicroserviceFactory method testInit.
@Test
public void testInit() {
MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
loader.loadAndSort();
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
MicroserviceFactory factory = new MicroserviceFactory();
Microservice microservice = factory.create(microserviceDefinition);
String microserviceName = "default";
Assert.assertEquals(microserviceName, microservice.getServiceName());
}
use of org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition in project incubator-servicecomb-java-chassis by apache.
the class TestPropertiesLoader method testInvalidExtendedClass.
@Test
public void testInvalidExtendedClass() {
ConfigModel configModel = MicroserviceDefinition.createConfigModel("default", "invalidExtendedClass");
@SuppressWarnings("unchecked") Map<String, Object> desc = (Map<String, Object>) configModel.getConfig().get(CONFIG_SERVICE_DESCRIPTION_KEY);
desc.put("propertyExtentedClass", "invalidClass");
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(Arrays.asList(configModel));
try {
microserviceFactory.create(microserviceDefinition);
Assert.fail("Must throw exception");
} catch (Error e) {
Assert.assertEquals(ClassNotFoundException.class, e.getCause().getClass());
Assert.assertEquals("invalidClass", e.getCause().getMessage());
}
}
use of org.apache.servicecomb.serviceregistry.definition.MicroserviceDefinition in project incubator-servicecomb-java-chassis by apache.
the class ServiceRegistryFactory method createLocal.
public static ServiceRegistry createLocal() {
EventBus eventBus = new EventBus();
ServiceRegistryConfig serviceRegistryConfig = ServiceRegistryConfig.INSTANCE;
MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
loader.loadAndSort();
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
return new LocalServiceRegistry(eventBus, serviceRegistryConfig, microserviceDefinition);
}
Aggregations