List of usage examples for org.apache.commons.configuration PropertiesConfiguration clearProperty
public void clearProperty(String key)
From source file:org.sakuli.utils.SakuliPropertyPlaceholderConfigurer.java
/** * writes the {@link SahiProxyProperties#PROXY_PORT} value as {@link SahiProxyProperties#SAHI_PROPERTY_PROXY_PORT_MAPPING} * property to sahiConfigPropertyFilePath! *//*from w w w .j av a 2 s . c om*/ protected void modifySahiProxyPortPropertiesConfiguration(String sahiConfigPropertyFilePath, Properties props) { final String sahiProxyPort = props.getProperty(SahiProxyProperties.PROXY_PORT); if (sahiProxyPort != null) { try { PropertiesConfiguration propConfig = new PropertiesConfiguration(sahiConfigPropertyFilePath); propConfig.setAutoSave(true); final String sahiMappingPropertyProxyPort = SahiProxyProperties.SAHI_PROPERTY_PROXY_PORT_MAPPING; if (propConfig.containsKey(sahiMappingPropertyProxyPort)) { propConfig.clearProperty(sahiMappingPropertyProxyPort); } //remove property after the test execution, so that the installation can't break addToModifiedPropertiesMap(sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, null); propConfig.addProperty(sahiMappingPropertyProxyPort, sahiProxyPort); logger.debug("modify properties file '{}' with '{}={}'", sahiConfigPropertyFilePath, sahiMappingPropertyProxyPort, sahiProxyPort); } catch (ConfigurationException e) { logger.error("modify sahi properties went wrong", e); } } }
From source file:org.sakuli.utils.SakuliPropertyPlaceholderConfigurer.java
/** * Modifies the properties file 'propFilePathToConfig' with assigned key from the resource properties. */// w w w. j av a 2s . co m protected void modifyPropertiesConfiguration(String propFilePathToConfig, List<String> updateKeys, Properties resourceProps) { try { PropertiesConfiguration propConfig = new PropertiesConfiguration(propFilePathToConfig); propConfig.setAutoSave(true); Properties temProps = new Properties(); for (String propKey : updateKeys) { String resolve = resolve(resourceProps.getProperty(propKey), resourceProps); if (resolve != null) { if (propConfig.containsKey(propKey)) { addToModifiedPropertiesMap(propFilePathToConfig, propKey, propConfig.getProperty(propKey)); propConfig.clearProperty(propKey); } temProps.put(propKey, resolve); propConfig.addProperty(propKey, resolve); } } logger.debug("modify properties file '{}' with '{}'", propFilePathToConfig, temProps.toString()); } catch (ConfigurationException e) { logger.error("modify sahi properties went wrong", e); } }