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.batch.MavenProjectBuilderTest.java

@Test
public void manyExclusionPatterns() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*,foo,*/bar");

    Project project = new Project("key");
    builder.configure(project, configuration);

    assertThat(project.getExclusionPatterns().length, is(3));
    assertThat(project.getExclusionPatterns()[0], is("**/*"));
    assertThat(project.getExclusionPatterns()[1], is("foo"));
    assertThat(project.getExclusionPatterns()[2], is("*/bar"));
}

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

@Test
public void getLanguageFromConfiguration() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.PROJECT_LANGUAGE_PROPERTY, "foo");

    Project project = new Project("key");
    builder.configure(project, configuration);

    assertThat(project.getLanguageKey(), is("foo"));
}

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

@Test
public void analysisDateCouldBeExplicitlySet() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.PROJECT_DATE_PROPERTY, "2005-01-30");
    Project project = new Project("key");
    builder.configure(project, configuration);

    assertEquals("30012005", new SimpleDateFormat("ddMMyyyy").format(project.getAnalysisDate()));
}

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

@Test(expected = RuntimeException.class)
public void failIfAnalyisDateIsNotValid() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.PROJECT_DATE_PROPERTY, "2005/30/01");
    Project project = new Project("key");
    builder.configure(project, configuration);

    project.getAnalysisDate();//from ww  w  . ja v  a 2s  . co m
}

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

@Test
public void sonarLightIsDeprecated() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty("sonar.light", "true");
    Project project = new Project("key");
    builder.configure(project, configuration);

    assertThat(project.getAnalysisType(), is(Project.AnalysisType.STATIC));
}

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

@Test
public void explicitDynamicAnalysis() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.DYNAMIC_ANALYSIS_PROPERTY, "true");
    Project project = new Project("key");
    builder.configure(project, configuration);
    assertThat(project.getAnalysisType(), is(Project.AnalysisType.DYNAMIC));
}

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

@Test
public void explicitStaticAnalysis() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.DYNAMIC_ANALYSIS_PROPERTY, "false");
    Project project = new Project("key");
    builder.configure(project, configuration);
    assertThat(project.getAnalysisType(), is(Project.AnalysisType.STATIC));
}

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

@Test
public void explicitDynamicAnalysisReusingReports() {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.DYNAMIC_ANALYSIS_PROPERTY, "reuseReports");
    Project project = new Project("key");
    builder.configure(project, configuration);
    assertThat(project.getAnalysisType(), is(Project.AnalysisType.REUSE_REPORTS));
}

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

@Test
public void isLatestAnalysis() {
    setupData("isLatestAnalysis");

    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.PROJECT_DATE_PROPERTY, "2010-12-25");

    Project project = new Project("my:key");
    builder.configure(project, configuration);

    assertThat(project.isLatestAnalysis(), is(true));
}

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

@Test
public void isLatestAnalysisIfNeverAnalysed() {
    setupData("isLatestAnalysisIfNeverAnalysed");

    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.setProperty(CoreProperties.PROJECT_DATE_PROPERTY, "2010-12-25");

    Project project = new Project("my:key");
    builder.configure(project, configuration);

    assertThat(project.isLatestAnalysis(), is(true));
}