aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/test/java/org')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/configuration/ProfilesBackupTest.java4
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/EnableProfilesTest.java63
2 files changed, 65 insertions, 2 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesBackupTest.java b/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesBackupTest.java
index dfec8d7d3a1..2387aba138f 100644
--- a/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesBackupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/configuration/ProfilesBackupTest.java
@@ -119,8 +119,8 @@ public class ProfilesBackupTest extends AbstractDbUnitTestCase {
RulesProfile testProfile = new RulesProfile("testProfile", "lang", false, false);
ActiveRule ar = new ActiveRule(null, new Rule("testPlugin", "testKey"), RulePriority.MAJOR);
ar.getActiveRuleParams().add(new ActiveRuleParam(null, new RuleParam(null, "paramKey", null, null), "testValue"));
- testProfile.getActiveRules().add(ar);
- testProfile.getActiveRules().add(new ActiveRule(null, new Rule("testPlugin", "testKey2"), RulePriority.MINOR));
+ testProfile.addActiveRule(ar);
+ testProfile.addActiveRule(new ActiveRule(null, new Rule("testPlugin", "testKey2"), RulePriority.MINOR));
testProfile.getAlerts().add(new Alert(null, new Metric("testKey"), Alert.OPERATOR_EQUALS, "10", "22"));
testProfile.getAlerts().add(new Alert(null, new Metric("testKey2"), Alert.OPERATOR_GREATER, "10", "22"));
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/EnableProfilesTest.java b/sonar-server/src/test/java/org/sonar/server/startup/EnableProfilesTest.java
new file mode 100644
index 00000000000..c7ec1fec395
--- /dev/null
+++ b/sonar-server/src/test/java/org/sonar/server/startup/EnableProfilesTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.startup;
+
+import org.junit.Test;
+import org.sonar.api.resources.AbstractLanguage;
+import org.sonar.api.resources.Java;
+import org.sonar.api.resources.Language;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
+
+public class EnableProfilesTest extends AbstractDbUnitTestCase {
+
+ @Test
+ public void shouldDisableProfilesWithMissingLanguages() {
+ setupData("shouldDisableProfilesWithMissingLanguages");
+
+ Language[] languages = new Language[]{Java.INSTANCE, new Php()};
+ EnableProfiles task = new EnableProfiles(languages, getSessionFactory(), null);
+ task.start();
+
+ checkTables("shouldDisableProfilesWithMissingLanguages", "rules_profiles");
+ }
+
+ @Test
+ public void shouldEnableProfilesWithKnownLanguages() {
+ setupData("shouldEnableProfilesWithKnownLanguages");
+
+ Language[] languages = new Language[]{Java.INSTANCE, new Php()};
+ EnableProfiles task = new EnableProfiles(languages, getSessionFactory(), null);
+ task.start();
+
+ checkTables("shouldEnableProfilesWithKnownLanguages", "rules_profiles");
+ }
+
+ private static class Php extends AbstractLanguage {
+
+ public Php() {
+ super("php");
+ }
+
+ public String[] getFileSuffixes() {
+ return new String[0];
+ }
+ }
+}
+