List of usage examples for org.apache.commons.configuration PropertiesConfiguration setProperty
public void setProperty(String key, Object value)
From source file:org.sonar.plugins.core.batch.ExcludedResourceFilterTest.java
/** * See SONAR-1115 Exclusion patterns do not apply to unit tests. *//*from w w w .j a va 2s . com*/ @Test public void ignoreResourceIfMatchesPattern() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, new String[] { "**/foo/*.java", "**/bar/*" }); Project project = new Project("foo").setConfiguration(conf); ExcludedResourceFilter filter = new ExcludedResourceFilter(project); Resource resource = mock(Resource.class); when(resource.matchFilePattern("**/bar/*")).thenReturn(true); assertThat(filter.isIgnored(resource), is(true)); }
From source file:org.sonar.plugins.core.batch.ExcludedResourceFilterTest.java
@Test public void doNotExcludeUnitTestFiles() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, new String[] { "**/foo/*.java", "**/bar/*" }); Project project = new Project("foo").setConfiguration(conf); ExcludedResourceFilter filter = new ExcludedResourceFilter(project); Resource unitTest = mock(Resource.class); when(unitTest.getQualifier()).thenReturn(Qualifiers.UNIT_TEST_FILE); // match exclusion pattern// www. j a va 2 s . com when(unitTest.matchFilePattern("**/bar/*")).thenReturn(true); assertThat(filter.isIgnored(unitTest), is(false)); }
From source file:org.sonar.plugins.core.sensors.FileHashSensorTest.java
@Before public void prepare() { fileSystem = mock(ModuleFileSystem.class); componentDataCache = mock(ComponentDataCache.class); sensor = new FileHashSensor(fileSystem, new PathResolver(), new HashBuilder(), componentDataCache); PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty("sonar.language", "java"); project = new Project("java_project").setConfiguration(conf).setLanguage(Java.INSTANCE); }
From source file:org.sonar.plugins.core.timemachine.TimeMachineConfigurationTest.java
@Test public void shouldSkipTendencies() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(CoreProperties.SKIP_TENDENCIES_PROPERTY, true); assertThat(new TimeMachineConfiguration(conf).skipTendencies(), is(true)); }
From source file:org.sonar.plugins.cpd.CpdSensorTest.java
private Project createJavaProject() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty("sonar.language", "java"); return new Project("java_project").setConfiguration(conf).setLanguage(Java.INSTANCE); }
From source file:org.sonar.plugins.cpd.CpdSensorTest.java
private Project createPhpProject() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty("sonar.language", "php"); Language phpLanguage = mock(Language.class); return new Project("php_project").setConfiguration(conf).setLanguage(phpLanguage); }
From source file:org.sonar.plugins.cpd.PmdEngineTest.java
@Test public void generalMinimumTokens() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty("sonar.cpd.minimumTokens", "33"); Project project = createJavaProject().setConfiguration(conf); PmdEngine engine = new PmdEngine(); assertEquals(33, engine.getMinimumTokens(project)); }
From source file:org.sonar.plugins.cpd.PmdEngineTest.java
@Test public void minimumTokensByLanguage() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty("sonar.cpd.minimumTokens", "100"); conf.setProperty("sonar.cpd.php.minimumTokens", "33"); Project phpProject = createPhpProject().setConfiguration(conf); Project javaProject = createJavaProject().setConfiguration(conf); PmdEngine engine = new PmdEngine(); assertEquals(100, engine.getMinimumTokens(javaProject)); assertEquals(33, engine.getMinimumTokens(phpProject)); }
From source file:org.sonar.plugins.cpd.SonarBridgeEngineTest.java
private static Project newProject(String key, String language) { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty("sonar.language", language); return new Project(key).setConfiguration(conf).setAnalysisType(Project.AnalysisType.DYNAMIC); }
From source file:org.sonar.plugins.dbcleaner.api.PurgeUtilsTest.java
@Test public void shouldReturnMinimumPeriod() { PropertiesConfiguration conf = new PropertiesConfiguration(); conf.setProperty(PurgeUtils.PROP_KEY_MINIMUM_PERIOD_IN_HOURS, "9"); assertThat(PurgeUtils.getMinimumPeriodInHours(conf), is(9)); }