Example usage for org.apache.commons.configuration BaseConfiguration BaseConfiguration

List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration

Introduction

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

Prototype

BaseConfiguration

Source Link

Usage

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

@Test
public void shouldFind() {
    Configuration conf = new BaseConfiguration();
    conf.addProperty("sonar.timemachine.period5", "1.2");

    when(finderByVersion.findByVersion(null, "1.2"))
            .thenReturn(new PastSnapshot("version", new Date(), new Snapshot()));

    PastSnapshot variationSnapshot = finder.find(null, conf, 5);

    verify(finderByVersion).findByVersion(null, "1.2");
    assertThat(variationSnapshot.getIndex(), is(5));
    assertThat(variationSnapshot.getMode(), is("version"));
    assertThat(variationSnapshot.getProjectSnapshot(), not(nullValue()));
}

From source file:org.sonar.batch.config.BatchSettingsTest.java

@Test
public void shouldLoadBuildModel() {
    // this is the project as defined in the build tool
    ProjectDefinition project = ProjectDefinition.create();
    project.setProperty("foo", "bar");

    ProjectReactor reactor = new ProjectReactor(project);
    BatchSettings settings = new BatchSettings(new PropertyDefinitions(), reactor, new BaseConfiguration());

    assertThat(settings.getString("foo"), is("bar"));
}

From source file:org.sonar.batch.config.BatchSettingsTest.java

@Test
public void environmentShouldOverrideBuildModel() {
    ProjectDefinition project = ProjectDefinition.create();
    project.setProperty("BatchSettingsTest.testEnv", "build");
    System.setProperty("BatchSettingsTest.testEnv", "env");

    ProjectReactor reactor = new ProjectReactor(project);
    BatchSettings settings = new BatchSettings(new PropertyDefinitions(), reactor, new BaseConfiguration());

    assertThat(settings.getString("BatchSettingsTest.testEnv"), is("env"));
}

From source file:org.sonar.batch.config.BatchSettingsTest.java

@Test
public void shouldForwardToCommonsConfiguration() {
    ProjectDefinition project = ProjectDefinition.create();
    project.setProperty("foo", "bar");

    ProjectReactor reactor = new ProjectReactor(project);
    BaseConfiguration deprecatedConfiguration = new BaseConfiguration();
    new BatchSettings(new PropertyDefinitions(), reactor, deprecatedConfiguration);

    assertThat(deprecatedConfiguration.getString("foo"), is("bar"));
}

From source file:org.sonar.java.api.JavaUtilsTest.java

@Test
public void shouldReturnDefaultJavaVersion() {
    BaseConfiguration configuration = new BaseConfiguration();
    Project project = new Project("").setConfiguration(configuration);

    assertThat(JavaUtils.getSourceVersion(project), is("1.5"));
    assertThat(JavaUtils.getTargetVersion(project), is("1.5"));
}

From source file:org.sonar.java.api.JavaUtilsTest.java

@Test
public void shouldReturnSpecifiedJavaVersion() {
    BaseConfiguration configuration = new BaseConfiguration();
    Project project = new Project("").setConfiguration(configuration);
    configuration.setProperty(JavaUtils.JAVA_SOURCE_PROPERTY, "1.4");
    configuration.setProperty(JavaUtils.JAVA_TARGET_PROPERTY, "1.6");

    assertThat(JavaUtils.getSourceVersion(project), is("1.4"));
    assertThat(JavaUtils.getTargetVersion(project), is("1.6"));
}

From source file:org.sonar.plugins.branding.LogoFooterTest.java

@Before
public void setUp() {
    conf = new BaseConfiguration();
    footer = new LogoFooter(conf);
}

From source file:org.sonar.plugins.buildstability.BuildStabilitySensorTest.java

@Test
public void urlInConfigurationTakesPrecedence() throws Exception {
    MavenProject mavenProject = new MavenProject();
    CiManagement ciManagement = new CiManagement();
    ciManagement.setSystem("Hudson");
    ciManagement.setUrl("pom");
    mavenProject.setCiManagement(ciManagement);
    Configuration configuration = new BaseConfiguration();
    configuration.setProperty(BuildStabilitySensor.CI_URL_PROPERTY, "Hudson:conf");
    Project project = mock(Project.class);
    when(project.getPom()).thenReturn(mavenProject);
    when(project.getConfiguration()).thenReturn(configuration);

    assertThat(sensor.getCiUrl(project), is("Hudson:conf"));
}

From source file:org.sonar.plugins.checkstyle.CheckstyleProfileExporter.java

/**
 * for unit tests
 */
CheckstyleProfileExporter() {
    this(new BaseConfiguration());
}

From source file:org.sonar.plugins.checkstyle.CheckstyleProfileExporterTest.java

@Test
public void addCustomFilters() throws IOException, SAXException {
    Configuration conf = new BaseConfiguration();
    conf.addProperty(CheckstyleConstants.FILTERS_KEY, "<module name=\"SuppressionCommentFilter\">"
            + "<property name=\"offCommentFormat\" value=\"BEGIN GENERATED CODE\"/>"
            + "<property name=\"onCommentFormat\" value=\"END GENERATED CODE\"/>" + "</module>"
            + "<module name=\"SuppressWithNearbyCommentFilter\">"
            + "<property name=\"commentFormat\" value=\"CHECKSTYLE IGNORE (\\w+) FOR NEXT (\\d+) LINES\"/>"
            + "<property name=\"checkFormat\" value=\"$1\"/>"
            + "<property name=\"messageFormat\" value=\"$2\"/>" + "</module>");

    RulesProfile profile = RulesProfile.create("sonar way", "java");
    StringWriter writer = new StringWriter();
    new CheckstyleProfileExporter(conf).exportProfile(profile, writer);

    TestUtils.assertSimilarXml(/*ww  w.j  ava  2  s .  co m*/
            TestUtils.getResourceContent(
                    "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomFilters.xml"),
            sanitizeForTests(writer.toString()));
}