SimpleConfig extends AbstractConfig implements RepositoryChangeListener { @Override public String getProperty(String key, String defaultValue) { if (m_configProperties == null) { logger.warn("Could not load config from Apollo, always return default value!"); return defaultValue; } return this.m_configProperties.getProperty(key, defaultValue); } SimpleConfig(String namespace, ConfigRepository configRepository); @Override String getProperty(String key, String defaultValue); @Override Set<String> getPropertyNames(); @Override ConfigSourceType getSourceType(); @Override synchronized void onRepositoryChange(String namespace, Properties newProperties);  }
@Test public void testGetProperty() throws Exception { Properties someProperties = new Properties(); String someKey = "someKey"; String someValue = "someValue"; someProperties.setProperty(someKey, someValue); someSourceType = ConfigSourceType.LOCAL; when(configRepository.getConfig()).thenReturn(someProperties); when(configRepository.getSourceType()).thenReturn(someSourceType); SimpleConfig config = new SimpleConfig(someNamespace, configRepository); assertEquals(someValue, config.getProperty(someKey, null)); assertEquals(someSourceType, config.getSourceType()); }