DefaultConfig extends AbstractConfig implements RepositoryChangeListener { @Override public Set<String> getPropertyNames() { Properties properties = m_configProperties.get(); if (properties == null) { return Collections.emptySet(); } return stringPropertyNames(properties); } DefaultConfig(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 testGetPropertyNames() { String someKeyPrefix = "someKey"; String someValuePrefix = "someValue"; someProperties = new Properties(); for (int i = 0; i < 10; i++) { someProperties.setProperty(someKeyPrefix + i, someValuePrefix + i); } when(configRepository.getConfig()).thenReturn(someProperties); DefaultConfig defaultConfig = new DefaultConfig(someNamespace, configRepository); Set<String> propertyNames = defaultConfig.getPropertyNames(); assertEquals(10, propertyNames.size()); assertEquals(someProperties.stringPropertyNames(), propertyNames); }
@Test public void testGetPropertyNamesWithNullProp() { when(configRepository.getConfig()).thenReturn(null); DefaultConfig defaultConfig = new DefaultConfig(someNamespace, configRepository); Set<String> propertyNames = defaultConfig.getPropertyNames(); assertEquals(Collections.emptySet(), propertyNames); }