PropertiesFileConfiguration implements IConfiguration { @Override public void update( Properties newProperties ) throws IOException { if ( properties == null ) { loadProperties(); } synchronized ( properties ) { long unixTime = System.currentTimeMillis() / 1000L; properties.store( new FileOutputStream( propFile + "." + String.valueOf( unixTime ) ), "" ); properties.clear(); properties.putAll( newProperties ); } synchronized ( propFile ) { properties.store( new FileOutputStream( propFile ), "" ); } } PropertiesFileConfiguration( String id, Properties properties );  PropertiesFileConfiguration( String id, File propFile ); @Override String getId(); @Override Properties getProperties(); @Override void update( Properties newProperties );  }
@Test public void testUpdate() throws Exception { Properties props = new Properties(); props.put( "one", "1" ); PropertiesFileConfiguration config = new PropertiesFileConfiguration( "id", props ); final File tmpPropsFile = File.createTempFile( "PropertiesFileConfiguratorTest", ".properties" ); config.setPropFile( tmpPropsFile ); Properties newProps = new Properties(); props.put( "two", "2" ); config.update( newProps ); Collection<File> files = FileUtils.listFiles( tmpPropsFile.getParentFile(), new IOFileFilter() { @Override public boolean accept( File file ) { return file.getName().startsWith( tmpPropsFile.getName() ); } @Override public boolean accept( File file, String s ) { return file.getName().startsWith( tmpPropsFile.getName() ); } }, null ); assertEquals( 2, files.size() ); for ( File file : files ) { file.deleteOnExit(); } }