List of usage examples for org.apache.commons.configuration Configuration setProperty
void setProperty(String key, Object value);
From source file:org.sonar.batch.BatchPluginRepositoryTest.java
@Test public void shouldActivateOldVersionOfJacoco() { Configuration conf = new PropertiesConfiguration(); conf.setProperty(AbstractCoverageExtension.PARAM_PLUGIN, "cobertura,jacoco"); BatchPluginRepository repository = new BatchPluginRepository(); assertThat(repository.shouldRegisterCoverageExtension("sonar-jacoco-plugin", newJavaProject(), conf), is(true));/* w w w . ja v a 2s . co m*/ assertThat(repository.shouldRegisterCoverageExtension("jacoco", newJavaProject(), conf), is(true)); assertThat(repository.shouldRegisterCoverageExtension("emma", newJavaProject(), conf), is(false)); }
From source file:org.sonar.batch.BatchPluginRepositoryTest.java
@Test public void shouldNotCheckCoverageExtensionsOnNonJavaProjects() { Configuration conf = new PropertiesConfiguration(); conf.setProperty(AbstractCoverageExtension.PARAM_PLUGIN, "cobertura"); BatchPluginRepository repository = new BatchPluginRepository(); assertThat(repository.shouldRegisterCoverageExtension("groovy", newGroovyProject(), conf), is(true)); assertThat(repository.shouldRegisterCoverageExtension("groovy", newJavaProject(), conf), is(false)); }
From source file:org.sonar.core.config.ConfigurationUtils.java
public static void copyToCommonsConfiguration(Map<String, String> input, Configuration commonsConfig) { // update deprecated configuration commonsConfig.clear();/* w w w . j a va 2 s . co m*/ for (Map.Entry<String, String> entry : input.entrySet()) { String key = entry.getKey(); commonsConfig.setProperty(key, entry.getValue()); } }
From source file:org.sonar.jpa.session.AbstractDatabaseConnectorTest.java
@Test public void useConfiguredDialectByDefault() { Configuration conf = MemoryDatabaseConnector.getInMemoryConfiguration(false); conf.setProperty(DatabaseProperties.PROP_DIALECT, DatabaseProperties.DIALECT_ORACLE); TestDatabaseConnector connector = new TestDatabaseConnector(conf); connector.start();/*from w ww. ja v a2 s .c o m*/ assertEquals(Oracle.class, connector.getDialect().getClass()); connector.stop(); }
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.clover.CloverMavenInitializer.java
@Override public void execute(Project project) { Configuration conf = project.getConfiguration(); if (!conf.containsKey(CloverConstants.REPORT_PATH_PROPERTY)) { String report = getReportPathFromPluginConfiguration(project); if (report == null) { report = getDefaultReportPath(project); }//w ww .j a v a 2s. co m conf.setProperty(CloverConstants.REPORT_PATH_PROPERTY, report); } }
From source file:org.sonar.plugins.cobertura.CoberturaMavenInitializer.java
@Override public void execute(Project project) { Configuration conf = project.getConfiguration(); if (conf.containsKey(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY)) { String report = getReportPathFromPluginConfiguration(project); if (report == null) { report = getDefaultReportPath(project); }/*from w w w .ja va 2 s . c om*/ conf.setProperty(CoreProperties.COBERTURA_REPORT_PATH_PROPERTY, report); } }
From source file:org.sonar.plugins.codesize.LineCounterTest.java
@Test public void customProfile() { LineCounter lineCounter = new LineCounter(); Configuration configuration = new PropertiesConfiguration(); configuration.setProperty(CodesizeConstants.SONAR_CODESIZE_PROFILE, "Java\nincludes=src/main/java/**/*.java\nexcludes=src/main/java/**/*.java"); SizingProfile profile = new SizingProfile(configuration); int lines = lineCounter.calculateLinesOfCode(new File("."), profile.getFileSetDefinitions().get(0)); assertEquals(0, lines);//from ww w. j a va 2s . com }
From source file:org.sonar.plugins.core.batch.MavenInitializer.java
@Override public void execute(Project project) { MavenProject pom = project.getPom(); Configuration conf = project.getConfiguration(); /*//from w ww. j ava 2 s. c om * See http://jira.codehaus.org/browse/SONAR-2148 * Get Java source and target versions from maven-compiler-plugin. */ if (StringUtils.isBlank(conf.getString(JavaUtils.JAVA_SOURCE_PROPERTY))) { String version = MavenUtils.getJavaSourceVersion(pom); conf.setProperty(JavaUtils.JAVA_SOURCE_PROPERTY, version); Logs.INFO.info("Java source version: {}", version); } if (StringUtils.isBlank(conf.getString(JavaUtils.JAVA_TARGET_PROPERTY))) { String version = MavenUtils.getJavaVersion(pom); conf.setProperty(JavaUtils.JAVA_TARGET_PROPERTY, version); Logs.INFO.info("Java target version: {}", version); } /* * See http://jira.codehaus.org/browse/SONAR-2151 * Get source encoding from POM */ if (StringUtils.isBlank(conf.getString(CoreProperties.ENCODING_PROPERTY))) { String encoding = MavenUtils.getSourceEncoding(pom); conf.setProperty(CoreProperties.ENCODING_PROPERTY, encoding); Logs.INFO.info("Source encoding: {}", encoding); } }
From source file:org.sonar.plugins.csharp.core.CSharpProjectInitializer.java
@Override public void execute(Project project) { Configuration projectConfiguration = project.getConfiguration(); // Handling encoding if (StringUtils.isBlank(projectConfiguration.getString("sonar.sourceEncoding", ""))) { LOG.info("'sonar.sourceEncoding' has not been defined: setting it to default value 'UTF-8'."); projectConfiguration.setProperty("sonar.sourceEncoding", "UTF-8"); }/*from w w w . java2 s. c om*/ // Handling exclusions if (projectConfiguration.getBoolean(CSharpConstants.EXCLUDE_GENERATED_CODE_KEY, CSharpConstants.EXCLUDE_GENERATED_CODE_DEFVALUE)) { String[] exclusions = projectConfiguration.getStringArray("sonar.exclusions"); Object[] newExclusions = ArrayUtils.addAll(exclusions, CSharpConstants.DEFAULT_FILES_TO_EXCLUDE); projectConfiguration.setProperty("sonar.exclusions", newExclusions); // TODO : remove the following line once SONAR-2827 has been fixed project.setExclusionPatterns(Arrays.asList(newExclusions).toArray(new String[newExclusions.length])); } }