ApolloDynamicConfiguration implements DynamicConfiguration { @Override public String getConfig(String key, String group, long timeout) throws IllegalStateException { if (StringUtils.isNotEmpty(group)) { if (group.equals(url.getParameter(APPLICATION_KEY))) { return ConfigService.getAppConfig().getProperty(key, null); } else { return ConfigService.getConfig(group).getProperty(key, null); } } return dubboConfig.getProperty(key, null); } ApolloDynamicConfiguration(URL url); @Override void addListener(String key, String group, ConfigurationListener listener); @Override void removeListener(String key, String group, ConfigurationListener listener); @Override String getConfig(String key, String group, long timeout); @Override String getProperties(String key, String group, long timeout); @Override String getInternalProperty(String key);  }
@Test public void testGetRule() { String mockKey = "mockKey1"; String mockValue = String.valueOf(new Random().nextInt()); putMockRuleData(mockKey, mockValue, DEFAULT_NAMESPACE); apolloDynamicConfiguration = new ApolloDynamicConfiguration(url); assertEquals(mockValue, apolloDynamicConfiguration.getConfig(mockKey, DEFAULT_NAMESPACE, 3000L)); mockKey = "notExistKey"; assertNull(apolloDynamicConfiguration.getConfig(mockKey, DEFAULT_NAMESPACE, 3000L)); }