diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2011-10-10 11:01:35 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2011-10-10 11:02:52 +0200 |
commit | 2800245cbd33f1932845276d3e6ea71c66da4f95 (patch) | |
tree | f3ecb64fc92f2337af66a7363b98be36c5ecc752 /sonar-batch | |
parent | 6c893bdf78ae76ae1df181923b647591522b0510 (diff) | |
download | sonarqube-2800245cbd33f1932845276d3e6ea71c66da4f95.tar.gz sonarqube-2800245cbd33f1932845276d3e6ea71c66da4f95.zip |
SONAR-2861 Remove unused classes ResourceDatabaseConfiguration and ProjectConfiguration
Diffstat (limited to 'sonar-batch')
5 files changed, 0 insertions, 252 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectConfiguration.java deleted file mode 100644 index 5e74b027b45..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/ProjectConfiguration.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.batch; - -import org.apache.commons.configuration.*; -import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.batch.bootstrap.ProjectReactor; -import org.sonar.api.database.DatabaseSession; - -public class ProjectConfiguration extends CompositeConfiguration { - private PropertiesConfiguration runtimeConfiguration; - - /** - * Used during batch startup - */ - public ProjectConfiguration(DatabaseSession session, ProjectReactor projectReactor) { - this(session, projectReactor.getRoot()); - } - - public ProjectConfiguration(DatabaseSession session, ProjectDefinition project) { - runtimeConfiguration = new PropertiesConfiguration(); - addConfiguration(runtimeConfiguration); - - loadSystemSettings(); - loadProjectDatabaseSettings(session, project); - addConfiguration(new MapConfiguration(project.getProperties())); - loadGlobalDatabaseSettings(session); - } - - private void loadProjectDatabaseSettings(DatabaseSession session, ProjectDefinition project) { - addConfiguration(new ResourceDatabaseConfiguration(session, project.getKey())); - - ProjectDefinition parent = project.getParent(); - while (parent != null && parent.getKey() != null) { - addConfiguration(new ResourceDatabaseConfiguration(session, parent.getKey())); - parent = parent.getParent(); - } - } - - private void loadGlobalDatabaseSettings(DatabaseSession session) { - addConfiguration(new org.sonar.api.database.configuration.DatabaseConfiguration(session)); - } - - private void loadSystemSettings() { - addConfiguration(new SystemConfiguration()); - addConfiguration(new EnvironmentConfiguration()); - } - - @Override - public void setProperty(String s, Object o) { - runtimeConfiguration.setProperty(s, o); - } -} diff --git a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfigurationTest.java b/sonar-batch/src/test/java/org/sonar/batch/ProjectConfigurationTest.java deleted file mode 100644 index 523a084e905..00000000000 --- a/sonar-batch/src/test/java/org/sonar/batch/ProjectConfigurationTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.batch; - -import org.apache.maven.project.MavenProject; -import org.junit.Test; -import org.sonar.api.batch.bootstrap.ProjectDefinition; -import org.sonar.api.resources.Project; -import org.sonar.jpa.test.AbstractDbUnitTestCase; - -import java.util.Properties; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; - -public class ProjectConfigurationTest extends AbstractDbUnitTestCase { - - @Test - public void loadSystemProperties() { - System.setProperty("foo", "bar"); - setupData("global-properties"); - - ProjectConfiguration config = new ProjectConfiguration(getSession(), newProject()); - assertThat(config.getString("foo"), is("bar")); - assertNull(config.getString("unknown")); - } - - @Test - public void loadDatabaseProperties() { - setupData("global-properties"); - ProjectConfiguration config = new ProjectConfiguration(getSession(), newProject()); - assertThat(config.getString("key1"), is("value1")); - assertNull(config.getString("key3")); - } - - @Test - public void loadProjectDatabaseProperties() { - setupData("project-properties"); - ProjectConfiguration config = new ProjectConfiguration(getSession(), newProject()); - assertThat(config.getString("key1"), is("overriden_value1")); - assertThat(config.getString("key2"), is("value2")); - assertThat(config.getString("key3"), is("value3")); - } - - @Test - public void loadModuleDatabaseProperties() { - setupData("modules-properties"); - ProjectConfiguration moduleConfig = new ProjectConfiguration(getSession(), newModule()); - - assertThat(moduleConfig.getString("key1"), is("project_value_1")); - assertThat(moduleConfig.getString("key2"), is("value_2")); - assertThat(moduleConfig.getString("key3"), is("module_value_3")); - assertThat(moduleConfig.getString("key4"), is("module_value_4")); - } - - @Test - public void mavenSettingsLoadedBeforeGlobalSettings() { - setupData("global-properties"); - ProjectDefinition project = newProject(); - project.setProperty("maven.foo", "bar"); - ProjectConfiguration config = new ProjectConfiguration(getSession(), project); - assertThat(config.getString("maven.foo"), is("bar")); - } - - @Test - public void projectSettingsLoadedBeforeMavenSettings() { - setupData("project-properties"); - ProjectDefinition project = newProject(); - project.setProperty("key1", "maven1"); - ProjectConfiguration config = new ProjectConfiguration(getSession(), project); - assertThat(config.getString("key1"), is("overriden_value1")); - } - - @Test - public void addPropertyAtRuntime() { - setupData("global-properties"); - ProjectConfiguration config = new ProjectConfiguration(getSession(), newProject()); - - config.getInMemoryConfiguration().setProperty("new-key", "new-value"); - assertThat(config.getString("new-key"), is("new-value")); - } - - @Test - public void overridePropertyAtRuntime() { - setupData("global-properties"); - ProjectConfiguration config = new ProjectConfiguration(getSession(), newProject()); - - assertThat(config.getString("key1"), is("value1")); - config.setProperty("key1", "new1"); - assertThat(config.getString("key1"), is("new1")); - } - - private ProjectDefinition newProject() { - return ProjectDefinition.create().setKey("mygroup:myproject"); - } - - private ProjectDefinition newModule() { - ProjectDefinition module = ProjectDefinition.create().setKey("mygroup:mymodule"); - ProjectDefinition project = newProject(); - project.addSubProject(module); - return module; - } -} diff --git a/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/global-properties.xml b/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/global-properties.xml deleted file mode 100644 index a0f67d7938d..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/global-properties.xml +++ /dev/null @@ -1,18 +0,0 @@ -<dataset> - - <!-- another project --> - <projects long_name="[null]" id="3333" scope="PRJ" qualifier="TRK" kee="mygroup:anotherproject" name="[null]" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <!-- global properties --> - <properties prop_key="key1" resource_id="[null]" text_value="value1"/> - <properties prop_key="key2" resource_id="[null]" text_value="value2"/> - - <!-- another project properties --> - <properties prop_key="key1" resource_id="3333" text_value="overriden value1"/> - <properties prop_key="key3" resource_id="3333" text_value="value3"/> - - -</dataset>
\ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/modules-properties.xml b/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/modules-properties.xml deleted file mode 100644 index 899e5d2cc02..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/modules-properties.xml +++ /dev/null @@ -1,26 +0,0 @@ -<dataset> - - <projects long_name="[null]" id="100" scope="PRJ" qualifier="TRK" kee="mygroup:myproject" name="[null]" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <projects long_name="[null]" id="101" scope="PRJ" qualifier="BRC" kee="mygroup:mymodule" name="[null]" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <!-- global properties --> - <properties prop_key="key1" resource_id="[null]" text_value="value_1"/> - <properties prop_key="key2" resource_id="[null]" text_value="value_2"/> - - <!-- project properties --> - <properties prop_key="key1" resource_id="100" text_value="project_value_1"/> - <properties prop_key="key3" resource_id="100" text_value="project_value_3"/> - - <!-- module properties --> - <properties prop_key="key3" resource_id="101" text_value="module_value_3"/> - <properties prop_key="key4" resource_id="101" text_value="module_value_4"/> - - -</dataset>
\ No newline at end of file diff --git a/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/project-properties.xml b/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/project-properties.xml deleted file mode 100644 index b8fa6538b72..00000000000 --- a/sonar-batch/src/test/resources/org/sonar/batch/ProjectConfigurationTest/project-properties.xml +++ /dev/null @@ -1,17 +0,0 @@ -<dataset> - - <projects long_name="[null]" id="100" scope="PRJ" qualifier="TRK" kee="mygroup:myproject" name="[null]" - root_id="[null]" - description="[null]" - enabled="true" language="java" copy_resource_id="[null]"/> - - <!-- global properties --> - <properties prop_key="key1" resource_id="[null]" text_value="value1"/> - <properties prop_key="key2" resource_id="[null]" text_value="value2"/> - - <!-- specific properties --> - <properties prop_key="key1" resource_id="100" text_value="overriden_value1"/> - <properties prop_key="key3" resource_id="100" text_value="value3"/> - - -</dataset>
\ No newline at end of file |