summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-01-07 12:03:52 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2013-01-07 12:03:52 +0100
commit51bd30be5e9e33dcf26126b74ace304ee839d1e0 (patch)
treecf50f6769d9058c05bbfc0379af54a3c4b609c03 /src/test/java/org
parenteb4a343f2252588057f9d5e86f5382a270ed1a69 (diff)
downloadsonar-scanner-cli-51bd30be5e9e33dcf26126b74ace304ee839d1e0.tar.gz
sonar-scanner-cli-51bd30be5e9e33dcf26126b74ace304ee839d1e0.zip
SONARPLUGINS-2297 The property sonar.sources should not be mandatory
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java53
1 files changed, 52 insertions, 1 deletions
diff --git a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java b/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
index 366c20f..7f88357 100644
--- a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
+++ b/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
@@ -165,6 +165,57 @@ public class SonarProjectBuilderTest {
// Module 1
ProjectDefinition module1 = modules.get(0);
assertThat(module1.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-module-definitions-in-each-module/module1"));
+ assertThat(module1.getKey()).isEqualTo("com.foo.project:com.foo.project.module1");
+ assertThat(module1.getName()).isEqualTo("Foo Module 1");
+ assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT");
+ // Description should not be inherited from parent if not set
+ assertThat(module1.getDescription()).isEqualTo("Description of Module 1");
+ assertThat(module1.getSourceDirs()).contains("sources");
+ assertThat(module1.getTestDirs()).contains("tests");
+ assertThat(module1.getBinaries()).contains("target/classes");
+ // and module properties must have been cleaned
+ assertThat(module1.getProperties().getProperty("module1.sonar.projectKey")).isNull();
+ assertThat(module1.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+
+ // Module 2
+ ProjectDefinition module2 = modules.get(1);
+ assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-module-definitions-in-each-module/module2/newBaseDir"));
+ assertThat(module2.getKey()).isEqualTo("com.foo.project:com.foo.project.module2");
+ assertThat(module2.getName()).isEqualTo("Foo Module 2");
+ assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT");
+ assertThat(module2.getDescription()).isEqualTo("Description of Module 2");
+ assertThat(module2.getSourceDirs()).contains("src");
+ assertThat(module2.getTestDirs()).contains("tests");
+ assertThat(module2.getBinaries()).contains("target/classes");
+ // and module properties must have been cleaned
+ assertThat(module2.getProperties().getProperty("module1.sonar.projectKey")).isNull();
+ assertThat(module2.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+ }
+
+ @Test
+ public void shouldDefineMultiModuleProjectWithDefinitionsModule1Inherited() throws IOException {
+ ProjectDefinition rootProject = loadProjectDefinition("multi-module-definitions-in-each-module-inherited");
+
+ // CHECK ROOT
+ assertThat(rootProject.getKey()).isEqualTo("com.foo.project");
+ assertThat(rootProject.getName()).isEqualTo("Foo Project");
+ assertThat(rootProject.getVersion()).isEqualTo("1.0-SNAPSHOT");
+ assertThat(rootProject.getDescription()).isEqualTo("Description of Foo Project");
+ // root project must not contain some properties - even if they are defined in the root properties file
+ assertThat(rootProject.getSourceDirs().contains("sources")).isFalse();
+ assertThat(rootProject.getTestDirs().contains("tests")).isFalse();
+ assertThat(rootProject.getBinaries().contains("target/classes")).isFalse();
+ // and module properties must have been cleaned
+ assertThat(rootProject.getProperties().getProperty("module1.sonar.projectKey")).isNull();
+ assertThat(rootProject.getProperties().getProperty("module2.sonar.projectKey")).isNull();
+
+ // CHECK MODULES
+ List<ProjectDefinition> modules = rootProject.getSubProjects();
+ assertThat(modules.size()).isEqualTo(2);
+
+ // Module 1
+ ProjectDefinition module1 = modules.get(0);
+ assertThat(module1.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-module-definitions-in-each-module-inherited/module1"));
assertThat(module1.getKey()).isEqualTo("com.foo.project:module1");
assertThat(module1.getName()).isEqualTo("module1");
assertThat(module1.getVersion()).isEqualTo("1.0-SNAPSHOT");
@@ -179,7 +230,7 @@ public class SonarProjectBuilderTest {
// Module 2
ProjectDefinition module2 = modules.get(1);
- assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-module-definitions-in-each-module/module2/newBaseDir"));
+ assertThat(module2.getBaseDir().getCanonicalFile()).isEqualTo(TestUtils.getResource(this.getClass(), "multi-module-definitions-in-each-module-inherited/module2/newBaseDir"));
assertThat(module2.getKey()).isEqualTo("com.foo.project:com.foo.project.module2");
assertThat(module2.getName()).isEqualTo("Foo Module 2");
assertThat(module2.getVersion()).isEqualTo("1.0-SNAPSHOT");