summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/test
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-09-28 12:10:05 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-09-28 12:10:05 +0000
commitd2f25e344d5db20b68339d52ad940e7f17edfc4d (patch)
tree08764c4c16267bf9265f885859d65831c5d25332 /sonar-server/src/test
parent51f793f7e9f643e12d148a9fac9a2ac79ef3da49 (diff)
downloadsonarqube-d2f25e344d5db20b68339d52ad940e7f17edfc4d.tar.gz
sonarqube-d2f25e344d5db20b68339d52ad940e7f17edfc4d.zip
SONAR-1814 remove the API to find a plugin from an extension :
* do register coverage extensions in picocontainer only when the plugin is selected (see parameter sonar.core.codeCoveragePlugin) * do not display plugin names when detecting a duplication of metrics * remove unused methods from the deprecated component RulesManager
Diffstat (limited to 'sonar-server/src/test')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java52
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java8
2 files changed, 56 insertions, 4 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java
new file mode 100644
index 00000000000..d6d3115e806
--- /dev/null
+++ b/sonar-server/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java
@@ -0,0 +1,52 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2009 SonarSource SA
+ * 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.server.plugins;
+
+import org.junit.Test;
+import org.sonar.api.BatchExtension;
+import org.sonar.api.ServerExtension;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+public class ServerPluginRepositoryTest {
+ @Test
+ public void shouldRegisterServerExtensions() {
+ ServerPluginRepository repository = new ServerPluginRepository();
+
+ // check classes
+ assertThat(repository.shouldRegisterExtension("foo", FakeBatchExtension.class), is(false));
+ assertThat(repository.shouldRegisterExtension("foo", FakeServerExtension.class), is(true));
+ assertThat(repository.shouldRegisterExtension("foo", String.class), is(false));
+
+ // check objects
+ assertThat(repository.shouldRegisterExtension("foo", new FakeBatchExtension()), is(false));
+ assertThat(repository.shouldRegisterExtension("foo", new FakeServerExtension()), is(true));
+ assertThat(repository.shouldRegisterExtension("foo", "foo"), is(false));
+ }
+
+ public static class FakeBatchExtension implements BatchExtension {
+
+ }
+
+ public static class FakeServerExtension implements ServerExtension {
+
+ }
+}
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java
index 2f2244e938a..49670f559ca 100644
--- a/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/startup/RegisterMetricsTest.java
@@ -41,7 +41,7 @@ public class RegisterMetricsTest extends AbstractDbUnitTestCase {
Metric metric1 = new Metric("new1", "short1", "desc1", Metric.ValueType.FLOAT, 1, true, "domain1", false);
Metric metric2 = new Metric("new2", "short2", "desc2", Metric.ValueType.FLOAT, 1, true, "domain2", false);
- RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null, null);
+ RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
synchronizer.register(Arrays.asList(metric1, metric2));
checkTables("shouldSaveIfNew", "metrics");
}
@@ -52,7 +52,7 @@ public class RegisterMetricsTest extends AbstractDbUnitTestCase {
final List<Metric> metrics = new ArrayList<Metric>();
metrics.add(new Metric("key", "new short name", "new description", Metric.ValueType.FLOAT, -1, true, "new domain", false));
- RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null, null);
+ RegisterMetrics synchronizer = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
synchronizer.register(metrics);
checkTables("shouldUpdateIfAlreadyExists", "metrics");
@@ -62,7 +62,7 @@ public class RegisterMetricsTest extends AbstractDbUnitTestCase {
public void enableOnlyLoadedMetrics() throws SQLException {
setupData("enableOnlyLoadedMetrics");
- RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null, null);
+ RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
loader.start();
assertFalse(getDao().getMeasuresDao().getMetric("deprecated").getEnabled());
@@ -73,7 +73,7 @@ public class RegisterMetricsTest extends AbstractDbUnitTestCase {
public void cleanAlerts() throws SQLException {
setupData("cleanAlerts");
- RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null, null);
+ RegisterMetrics loader = new RegisterMetrics(getSession(), new MeasuresDao(getSession()), null);
loader.cleanAlerts();
checkTables("cleanAlerts", "metrics", "alerts");