Example usage for org.apache.commons.configuration SubnodeConfiguration addProperty

List of usage examples for org.apache.commons.configuration SubnodeConfiguration addProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration SubnodeConfiguration addProperty.

Prototype

public void addProperty(String key, Object value) 

Source Link

Usage

From source file:com.github.technosf.posterer.transports.commons.CommonsConfiguratorPropertiesImpl.java

/**
 * {@inheritDoc}//  w  w  w  . ja va  2s.co  m
 * 
 * @see com.github.technosf.posterer.models.PropertiesModel#addData(com.github.technosf.posterer.models.impl.PropertiesModel.RequestData)
 */
@Override
public boolean addData(final RequestData propertyData) {
    boolean result = false;

    if (propertyData != null) {
        RequestBean pdi = new RequestBean(propertyData);
        if (pdi.isActionable() && (result = !requestProperties.containsKey(pdi.hashCode()))) {
            requestProperties.put(pdi.hashCode(), pdi);
            config.addProperty("requests/request@id", pdi.hashCode());
            SubnodeConfiguration property = getRequest(pdi.hashCode());
            property.addProperty("endpoint", pdi.getEndpoint());
            property.addProperty("payload", pdi.getPayload());
            property.addProperty("method", pdi.getMethod());
            property.addProperty("contentType", pdi.getContentType());
            property.addProperty("base64", pdi.getBase64());
            property.addProperty("httpUser", pdi.getHttpUser());
            property.addProperty("httpPassword", pdi.getHttpPassword());
            save();
        }
    }

    return result;
}

From source file:io.datalayer.conf.HierarchicalIniConfigurationTest.java

/**
 * Tests whether a section that was created by getSection() can be
 * manipulated.//from   ww w  .jav a2s  .c  om
 */
@Test
public void testGetSectionNonExistingManipulate() throws ConfigurationException {
    HierarchicalINIConfiguration config = setUpConfig(INI_DATA);
    SubnodeConfiguration section = config.getSection("newSection");
    section.addProperty("test", "success");
    assertEquals("Main config not updated", "success", config.getString("newSection.test"));
    StringWriter writer = new StringWriter();
    config.save(writer);
    HierarchicalINIConfiguration config2 = setUpConfig(writer.toString());
    section = config2.getSection("newSection");
    assertEquals("Wrong value", "success", section.getString("test"));
}