aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-09-10 18:47:24 +0200
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-09-11 09:18:23 +0200
commit7ba663bea3a7a7e55b946de6de96237781bef01f (patch)
tree22cb56b18831b091a90b4a6cb2c507c171a70212 /src/test
parent6861dd5abd3ccb2e53344ecf6b134f41ecc14107 (diff)
downloadsonar-scanner-cli-7ba663bea3a7a7e55b946de6de96237781bef01f.tar.gz
sonar-scanner-cli-7ba663bea3a7a7e55b946de6de96237781bef01f.zip
SONARPLUGINS-2202 Check unicity of module's key inside its parent
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java25
1 files changed, 25 insertions, 0 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 593323c..b0d3d8f 100644
--- a/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
+++ b/src/test/java/org/sonar/runner/internal/batch/SonarProjectBuilderTest.java
@@ -338,4 +338,29 @@ public class SonarProjectBuilderTest {
assertThat(props.getProperty("sonar.projectKey")).isEqualTo("my-parent-key:my-module-key");
}
+ @Test
+ public void shouldFailIf2ModulesWithSameKey() {
+ Properties props = new Properties();
+ props.put("sonar.projectKey", "root");
+ ProjectDefinition root = ProjectDefinition.create(props);
+
+ Properties props1 = new Properties();
+ props1.put("sonar.projectKey", "mod1");
+ root.addSubProject(ProjectDefinition.create(props1));
+
+ // Check unicity of a new module: OK
+ Properties props2 = new Properties();
+ props2.put("sonar.projectKey", "mod2");
+ ProjectDefinition mod2 = ProjectDefinition.create(props2);
+ SonarProjectBuilder.checkUnicityOfChildKey(mod2, root);
+
+ // Now, add it and check again
+ root.addSubProject(mod2);
+
+ thrown.expect(RunnerException.class);
+ thrown.expectMessage("Project 'root' can't have 2 modules with the following key: mod2");
+
+ SonarProjectBuilder.checkUnicityOfChildKey(mod2, root);
+ }
+
}