### Question:
SimpleRegistry extends AbstractRegistry { public void setFlowerFactory(FlowerFactory flowerFactory) { this.flowerFactory = flowerFactory; this.serviceInfoRegisterRouter = getServiceRouter("ServiceInfoRegisterService", ServiceInfo.class.getName(), Boolean.class.getName()); this.serviceInfoListRouter = getServiceRouter("ServiceInfoListService", ServiceInfo.class.getName(), HashSet.class.getName()); this.flowConfigRegisterRouter = getServiceRouter("FlowConfigRegisterService", FlowConfig.class.getName(), Boolean.class.getName()); this.flowConfigListRouter = getServiceRouter("FlowConfigListService", FlowConfig.class.getName(), HashSet.class.getName()); } SimpleRegistry(URL url); void setFlowerFactory(FlowerFactory flowerFactory); @Override boolean doRegister(ServiceInfo serviceInfo); @Override boolean doRegisterFlowConfig(FlowConfig serviceConfig); @Override List<ServiceInfo> doGetProvider(ServiceInfo serviceInfo); @Override List<FlowConfig> doGetFlowConfig(FlowConfig serviceConfig);  }### Answer:
@Test public void testRegister() throws Exception { URL url = new URL("flower", "127.0.0.1", 8096); url.addParam("application", "FlowerCenter"); RegistryFactory factory = new SimpleRegistryFactory(); Registry registry = factory.createRegistry(url); ((SimpleRegistry) registry).setFlowerFactory(flowerFactory); ServiceInfo serviceInfo = new ServiceInfo(); serviceInfo.setApplication(flowerFactory.getFlowerConfig().getName()); ServiceMeta meta = new ServiceMeta(UserServiceA.class.getName()); meta.setServiceName(UserServiceA.class.getName()); serviceInfo.setServiceMeta(meta); serviceInfo.setAddress(flowerFactory.getFlowerConfig().toURL()); serviceInfo.setCreateTime(new Date()); registry.register(serviceInfo); sleep = 10000; }
@Test public void testGetProviders() throws Exception { URL url = new URL("http", "127.0.0.1", 8096); url.addParam("application", "FlowerCenter"); RegistryFactory factory = new SimpleRegistryFactory(); Registry registry = factory.createRegistry(url); ((SimpleRegistry) registry).setFlowerFactory(flowerFactory); ServiceInfo serviceInfo = new ServiceInfo(); serviceInfo.setApplication(flowerFactory.getFlowerConfig().getName()); ServiceMeta meta = new ServiceMeta(UserServiceA.class.getName()); meta.setServiceName(UserServiceA.class.getName()); serviceInfo.setServiceMeta(meta); serviceInfo.setCreateTime(new Date()); List<ServiceInfo> serviceInfos = registry.getProvider(serviceInfo); System.out.println("请求结果:" + serviceInfos); }
@Test @Ignore public void testRegisterServiceConfig() { URL url = new URL("http", "127.0.0.1", 8080); RegistryFactory factory = ExtensionLoader.load(RegistryFactory.class).load(); Registry registry = factory.createRegistry(url); ((SimpleRegistry) registry).setFlowerFactory(flowerFactory); FlowConfig serviceConfig = ServiceFlow.getOrCreate("registerFlow", serviceFactory).buildFlow(UserServiceA.class, UserServiceB.class) .buildFlow(UserServiceB.class, UserServiceC1.class).getFlowConfig(); registry.registerFlowConfig(serviceConfig); }
@Test @Ignore public void testGetServiceConfig() throws Exception { URL url = new URL("http", "127.0.0.1", 8080); RegistryFactory factory = ExtensionLoader.load(RegistryFactory.class).load(); Registry registry = factory.createRegistry(url); ((SimpleRegistry) registry).setFlowerFactory(flowerFactory); List<FlowConfig> serviceInfos = registry.getFlowConfig(null); System.out.println("请求结果:" + serviceInfos); }