Example usage for org.apache.commons.configuration PropertiesConfiguration setProperty

List of usage examples for org.apache.commons.configuration PropertiesConfiguration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration PropertiesConfiguration setProperty.

Prototype

public void setProperty(String key, Object value) 

Source Link

Document

Sets a new value for the specified property.

Usage

From source file:org.soitoolkit.tools.generator.util.PropertyFileUtil.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public static void updateMuleDeployPropertyFileConfigFile(String outputFolder, String configFilename) {

    String muleDeployPropertyFile = outputFolder + "/src/main/app/mule-deploy.properties";
    System.err.println("Open muleDeployPropertyFile: " + muleDeployPropertyFile);

    try {//from  ww w. j  a  v  a 2 s. c o  m
        PropertiesConfiguration config = new PropertiesConfiguration(muleDeployPropertyFile);
        String key = "config.resources";
        List value = config.getList(key);
        value.add(configFilename);
        System.err.println("Update muleDeployPropertyFile: " + key + " = " + value);
        config.setProperty(key, value);
        config.save();
        System.err.println("Saved muleDeployPropertyFile");

    } catch (ConfigurationException e1) {
        System.err.println("Error with muleDeployPropertyFile: " + e1.getMessage());
        throw new RuntimeException(e1);
    }
}

From source file:org.sonar.ant.LauncherTest.java

@Test
public void shouldEnableVerboseMode() {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("sonar.verbose", "true");
    assertThat(launcher.getLoggerLevel(config), is("DEBUG"));
}

From source file:org.sonar.ant.LauncherTest.java

@Test
public void shouldDisableVerboseMode() {
    PropertiesConfiguration config = new PropertiesConfiguration();
    config.setProperty("sonar.verbose", "false");
    assertThat(launcher.getLoggerLevel(config), is("INFO"));
}

From source file:org.sonar.batch.BatchTest.java

@Test
public void shouldConvertCommonsConfigurationToProperties() {
    PropertiesConfiguration commonsConf = new PropertiesConfiguration();
    commonsConf.setProperty("foo", "Foo");
    commonsConf.setProperty("list", "One,Two");
    assertThat(commonsConf.getString("list"), is("One"));
    assertThat(commonsConf.getStringArray("list")[0], is("One"));
    assertThat(commonsConf.getStringArray("list")[1], is("Two"));

    Properties props = Batch.convertToProperties(commonsConf);
    assertThat(props.getProperty("foo"), is("Foo"));
    assertThat(props.getProperty("list"), is("One,Two"));
}

From source file:org.sonar.batch.components.PastSnapshotFinderTest.java

@Test
public void shouldGetPropertyValue() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty("sonar.timemachine.period1", "5");

    assertThat(PastSnapshotFinder.getPropertyValue(conf, 1), is("5"));
    assertThat(PastSnapshotFinder.getPropertyValue(conf, 999), nullValue());
}

From source file:org.sonar.batch.components.PastSnapshotFinderTest.java

@Test
public void shouldGetDefaultPropertyValue() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty("sonar.timemachine.period1", "5");

    assertThat(PastSnapshotFinder.getPropertyValue(conf, 2), is(CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2));
}

From source file:org.sonar.batch.components.TimeMachineConfigurationTest.java

@Test
public void shouldSkipTendencies() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(CoreProperties.SKIP_TENDENCIES_PROPERTY, true);
    assertThat(new TimeMachineConfiguration(getSession(), new Project("my:project"), conf,
            mock(PastSnapshotFinder.class)).skipTendencies(), is(true));
}

From source file:org.sonar.batch.DefaultProfileLoaderTest.java

private Project newProject(String language) {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty("sonar.language", language);
    return new Project("project").setConfiguration(configuration);
}

From source file:org.sonar.batch.index.DefaultResourcePersisterTest.java

private static Project newProject(String key, String language) {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty("sonar.language", language);
    return new Project(key).setConfiguration(configuration).setAnalysisType(Project.AnalysisType.DYNAMIC);
}

From source file:org.sonar.batch.MavenPhaseExecutorTest.java

@Test
public void executePhase() {
    MavenPluginExecutor mavenPluginExecutor = mock(MavenPluginExecutor.class);
    MavenPhaseExecutor phaseExecutor = new MavenPhaseExecutor(mavenPluginExecutor);

    Project project = new Project("key");
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(MavenPhaseExecutor.PROP_PHASE, "myphase");
    project.setConfiguration(conf);//from   w w  w.  ja  v  a  2  s  .c o m

    phaseExecutor.execute(project, mock(SensorContext.class));

    verify(mavenPluginExecutor).execute(project, "myphase");
}