]> source.dussan.org Git - sonarqube.git/commitdiff
Clone properties when creating ProjectDefinition
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 7 Jun 2011 16:27:35 +0000 (18:27 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 7 Jun 2011 16:32:26 +0000 (18:32 +0200)
sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java

index e824d4e0a8732bffe5533a4eace42dd4ce7111e3..b1b21a1bb3801436f4754318eb379f8916164de9 100644 (file)
@@ -59,7 +59,7 @@ public final class ProjectDefinition implements BatchComponent {
   }
 
   public static ProjectDefinition create(Properties properties) {
-    return new ProjectDefinition(properties);
+    return new ProjectDefinition((Properties)properties.clone());
   }
 
   public static ProjectDefinition create() {
index 581e9ff3361b6d44fa7ca4797924e6d329338e85..ad1cf8686661892dd26cd368c09d77f2a4bb9dc3 100644 (file)
@@ -146,6 +146,17 @@ public class ProjectDefinitionTest {
     assertThat(root.getTestDirs().size(), is(0));
   }
 
+  @Test
+  public void shouldCloneProperties()  {
+    Properties rootProps = new Properties();
+    rootProps.setProperty(CoreProperties.PROJECT_NAME_PROPERTY, "root");
+    ProjectDefinition def = ProjectDefinition.create(rootProps);
+    def.setName("child");
+
+    assertThat(def.getName(), is("child"));
+    assertThat(rootProps.getProperty(CoreProperties.PROJECT_NAME_PROPERTY), is("root"));
+  }
+
   private static void assertFiles(List<String> paths, String... values) {
     assertThat(paths.size(), is(values.length));
     for (int i = 0; i < values.length; i++) {