List of usage examples for org.apache.commons.configuration2 Configuration clear
void clear();
From source file:org.mitre.mpf.wfm.util.TestPropertiesUtil.java
@Test public void testBuilderSave() throws ConfigurationException, IOException { ImmutableConfiguration mpfPropertiesconfig = mpfPropertiesConfigurationBuilder.getCompleteConfiguration(); List<PropertyModel> newCustomPropertyModels = new ArrayList<>(); newCustomPropertyModels.add(new PropertyModel(FRAME_INTERVAL_KEY, "4", false)); newCustomPropertyModels.add(new PropertyModel(MODELS_DIR_KEY, "${" + SHARE_PATH_KEY + "}/new/dir/", false)); newCustomPropertyModels.add(new PropertyModel(TIMEOUT_KEY, "60", false)); ImmutableConfiguration newMpfPropertiesConfig = mpfPropertiesConfigurationBuilder .setAndSaveCustomProperties(newCustomPropertyModels); String mpfHome = System.getenv(MPF_HOME_ENV_VAR); Assert.assertNotNull(mpfHome);/*from w w w . ja v a 2s. com*/ // ensure that current config isn't modified Assert.assertEquals(1, mpfPropertiesconfig.getInt(FRAME_INTERVAL_KEY)); Assert.assertEquals(mpfHome + "/share/models/", mpfPropertiesconfig.getString(MODELS_DIR_KEY)); Assert.assertEquals(30, mpfPropertiesconfig.getInt(TIMEOUT_KEY)); // get updated config mpfPropertiesconfig = newMpfPropertiesConfig; // mpfPropertiesConfigurationBuilder.getConfiguration(); // ensure detection value sticks Assert.assertEquals(4, mpfPropertiesconfig.getInt(FRAME_INTERVAL_KEY)); // ensure that interpolation is performed on recently-set values Assert.assertEquals(mpfHome + "/share/new/dir/", mpfPropertiesconfig.getString(MODELS_DIR_KEY)); // ensure non-detection value doesn't stick Assert.assertEquals(30, mpfPropertiesconfig.getInt(TIMEOUT_KEY)); // ensure all values written to disk Configurations configs = new Configurations(); FileBasedConfigurationBuilder<PropertiesConfiguration> mpfCustomPropertiesConfigBuilder = configs .propertiesBuilder(customPropFile.getURL()); Configuration mpfCustomPropertiesConfig = mpfCustomPropertiesConfigBuilder.getConfiguration(); Assert.assertEquals(4, mpfCustomPropertiesConfig.getInt(FRAME_INTERVAL_KEY)); Assert.assertEquals("${" + SHARE_PATH_KEY + "}/new/dir/", mpfCustomPropertiesConfig.getString(MODELS_DIR_KEY)); Assert.assertEquals(60, mpfCustomPropertiesConfig.getInt(TIMEOUT_KEY)); // reset mpfCustomPropertiesConfig.clear(); mpfCustomPropertiesConfigBuilder.save(); }