PropertiesConfigFile extends AbstractConfigFile { @Override public String getContent() { if (m_contentCache.get() == null) { m_contentCache.set(doGetContent()); } return m_contentCache.get(); } PropertiesConfigFile(String namespace,
                              ConfigRepository configRepository); @Override String getContent(); @Override boolean hasContent(); @Override ConfigFileFormat getConfigFileFormat();  }
@Test public void testOnRepositoryChange() throws Exception { Properties someProperties = new Properties(); String someKey = "someKey"; String someValue = "someValue"; String anotherValue = "anotherValue"; someProperties.setProperty(someKey, someValue); when(configRepository.getConfig()).thenReturn(someProperties); PropertiesConfigFile configFile = new PropertiesConfigFile(someNamespace, configRepository); assertTrue(configFile.getContent().contains(String.format("%s=%s", someKey, someValue))); Properties anotherProperties = new Properties(); anotherProperties.setProperty(someKey, anotherValue); final SettableFuture<ConfigFileChangeEvent> configFileChangeFuture = SettableFuture.create(); ConfigFileChangeListener someListener = new ConfigFileChangeListener() { @Override public void onChange(ConfigFileChangeEvent changeEvent) { configFileChangeFuture.set(changeEvent); } }; configFile.addChangeListener(someListener); configFile.onRepositoryChange(someNamespace, anotherProperties); ConfigFileChangeEvent changeEvent = configFileChangeFuture.get(500, TimeUnit.MILLISECONDS); assertFalse(configFile.getContent().contains(String.format("%s=%s", someKey, someValue))); assertTrue(configFile.getContent().contains(String.format("%s=%s", someKey, anotherValue))); assertEquals(someNamespace, changeEvent.getNamespace()); assertTrue(changeEvent.getOldValue().contains(String.format("%s=%s", someKey, someValue))); assertTrue(changeEvent.getNewValue().contains(String.format("%s=%s", someKey, anotherValue))); assertEquals(PropertyChangeType.MODIFIED, changeEvent.getChangeType()); }