aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-12-20 20:56:20 +0100
committersimonbrandhof <simon.brandhof@gmail.com>2011-12-20 20:56:20 +0100
commit3abd667d979c3899a4f529a6e0dbf0e0dddb8245 (patch)
tree6c054804a5e0a631ab0ad76a8294cd43b1019b81 /sonar-batch/src/test
parent44096503cea425a43632dfa3e58da2cc1d28a35b (diff)
downloadsonarqube-3abd667d979c3899a4f529a6e0dbf0e0dddb8245.tar.gz
sonarqube-3abd667d979c3899a4f529a6e0dbf0e0dddb8245.zip
SONAR-2968 Do not force to add the root project to the property sonar.includedModules
Diffstat (limited to 'sonar-batch/src/test')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectFilterTest.java45
1 files changed, 27 insertions, 18 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectFilterTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectFilterTest.java
index d01f5150bf9..3d5b4eaa545 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectFilterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/ProjectFilterTest.java
@@ -22,51 +22,60 @@ package org.sonar.batch.bootstrap;
import org.junit.Test;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;
-import org.sonar.batch.config.ProjectSettings;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
public class ProjectFilterTest {
+ private Project root = new Project("root");
+
@Test
- public void testSkippedModule() {
+ public void testSkippedModules() {
Settings settings = new Settings();
settings.setProperty("sonar.skippedModules", "foo,bar");
ProjectFilter filter = new ProjectFilter(settings);
- assertTrue(filter.isExcluded(new Project("my:foo")));
+ assertTrue(filter.isExcluded(new Project("foo").setParent(root)));
+ assertFalse(filter.isExcluded(new Project("other").setParent(root)));
}
@Test
- public void testNotExcluded() {
+ public void shouldNotSkipRoot() {
Settings settings = new Settings();
- settings.setProperty("sonar.skippedModules", "foo,bar");
-
+ settings.setProperty("sonar.skippedModules", "root,foo,bar");
ProjectFilter filter = new ProjectFilter(settings);
- assertFalse(filter.isExcluded(new Project("my:other")));
+
+ assertFalse(filter.isExcluded(root));
}
+
@Test
public void testNoSkippedModules() {
Settings settings = new Settings();
-
ProjectFilter filter = new ProjectFilter(settings);
- assertFalse(filter.isExcluded(new Project("my:other")));
+
+ assertFalse(filter.isExcluded(new Project("foo").setParent(root)));
+ assertFalse(filter.isExcluded(root));
}
@Test
public void testIncludedModules() {
Settings settings = new Settings();
settings.setProperty("sonar.includedModules", "foo");
+ ProjectFilter filter = new ProjectFilter(settings);
+
+ assertFalse(filter.isExcluded(new Project("foo").setParent(root)));
+ assertTrue(filter.isExcluded(new Project("bar").setParent(root)));
+ }
+ @Test
+ public void shouldNotIncludeRoot() {
+ Settings settings = new Settings();
+ settings.setProperty("sonar.includedModules", "foo,bar");
ProjectFilter filter = new ProjectFilter(settings);
- assertFalse(filter.isExcluded(new Project("my:foo")));
- filter = new ProjectFilter(settings);
- assertTrue(filter.isExcluded(new Project("my:bar")));
+ assertFalse(filter.isExcluded(root));
}
@Test
@@ -74,11 +83,11 @@ public class ProjectFilterTest {
Settings settings = new Settings();
settings.setProperty("sonar.skippedModules", "parent");
- Project parent = new Project("my:parent");
- Project child = new Project("my:child");
- child.setParent(parent);
+ Project parent = new Project("parent").setParent(root);
+ Project child = new Project("child").setParent(parent);
ProjectFilter filter = new ProjectFilter(settings);
+ assertTrue(filter.isExcluded(parent));
assertTrue(filter.isExcluded(child));
}