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.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void testShouldNotExecuteOnNonPhpProjectWithSonarCpdSkipIsTrue() {
    Project project = createProject();//from   ww  w  .j av  a  2 s .c om
    project.setLanguage(Java.INSTANCE);
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty("sonar.cpd.skip", "true");

    testShouldRun(project, false);
}

From source file:org.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void testShouldExecuteOnProjectWhenCpdSkipPropertyFalse() {
    Project project = createProject();/*from w  ww. j ava2  s .com*/
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty("sonar.cpd.skip", "false");

    testShouldRun(project, true);
}

From source file:org.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void testShouldNotExecuteOnProjectWhenCpdSkipPropertyTrue() {
    Project project = createProject();//from   w ww.  j a va  2 s. c  o m
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty("sonar.cpd.skip", "true");

    testShouldRun(project, false);
}

From source file:org.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void testShouldExecuteOnProjectWhenCpdSkipPropertyNotSetButDeprecatedCpdSkipPropertyFalse() {
    Project project = createProject();/*from w  w w  .  j  a  v  a  2  s  . co m*/
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty("sonar.php.cpd.skip", "false");

    testShouldRun(project, true);
}

From source file:org.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void testShouldNotExecuteOnProjectWhenCpdSkipPropertyNotSetButDeprecatedCpdSkipPropertyTrue() {
    Project project = createProject();/*from   w  w  w  . j  a  v a  2 s.com*/
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty("sonar.php.cpd.skip", "true");

    testShouldRun(project, false);
}

From source file:org.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void testShouldExecuteOnProjectWhenBothCpdSkipPropertyNotSetButShouldRunPropertyTrue() {
    Project project = createProject();//from  www  . j a  v a 2s . c  om
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty(PHPCPD_SHOULD_RUN_PROPERTY_KEY, "true");

    testShouldRun(project, true);
}

From source file:org.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void testShouldNotExecuteOnProjectWhenBothCpdSkipPropertyNotSetButShouldRunPropertyFalse() {
    Project project = createProject();//w w  w  .  j  a v a2s  . c  om
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty(PHPCPD_SHOULD_RUN_PROPERTY_KEY, "false");

    testShouldRun(project, false);
}

From source file:org.sonar.plugins.php.cpd.PhpPhpCpdSensorTest.java

@Test
public void generalSkip() {

    PhpCpdConfiguration configuration = mock(PhpCpdConfiguration.class);
    Project project = createProject();/*from  w  w w.j a v  a  2s  . c o m*/
    PropertiesConfiguration conf = (PropertiesConfiguration) project.getConfiguration();
    conf.setProperty("sonar.cpd.skip", "true");
    conf.setProperty(PHPCPD_SHOULD_RUN_PROPERTY_KEY, "false");

    PhpCpdSensor sensor = new PhpCpdSensor(configuration, null, null);
    assertFalse(sensor.shouldExecuteOnProject(project));
}

From source file:org.sonar.plugins.switchoffviolations.SwitchOffViolationsFilterTest.java

@Test
public void shouldLoadConfigurationFile() throws IOException {
    File file = TestUtils.getResource(getClass(), "filter.txt");

    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(Constants.LOCATION_PARAMETER, file.getCanonicalPath());

    SwitchOffViolationsFilter filter = new SwitchOffViolationsFilter(conf);
    assertThat(filter.getPatterns().length, is(2));
    assertTrue(filter.isIgnored(Violation.create(CHECKSTYLE_RULE, JAVA_FILE).setLineId(150)));
}

From source file:org.sonar.plugins.switchoffviolations.SwitchOffViolationsFilterTest.java

@Test(expected = SonarException.class)
public void shouldFailIfFileNotFound() {
    PropertiesConfiguration conf = new PropertiesConfiguration();
    conf.setProperty(Constants.LOCATION_PARAMETER, "/path/to/unknown/file");
    new SwitchOffViolationsFilter(conf);
}