diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-01-27 23:27:26 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-01-27 23:28:03 +0100 |
commit | 36805421f21c3dbc2b0638d27ff9ece3d2cf3156 (patch) | |
tree | 82384bad6eae5720287bc8c79093455d8d624a37 /sonar-plugin-api/src/test/java/org/sonar/api/checks | |
parent | 08977044fa003bd252310c62287642630ba02d09 (diff) | |
download | sonarqube-36805421f21c3dbc2b0638d27ff9ece3d2cf3156.tar.gz sonarqube-36805421f21c3dbc2b0638d27ff9ece3d2cf3156.zip |
Move AnnotationCheckFactory to sonar-deprecated
Diffstat (limited to 'sonar-plugin-api/src/test/java/org/sonar/api/checks')
10 files changed, 0 insertions, 497 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java deleted file mode 100644 index abf1347d55f..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.RuleProperty; - -abstract class AbstractCheck { - - @RuleProperty - private Integer max; - - public Integer getMax() { - return max; - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java deleted file mode 100644 index a58cb83c499..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.Rule; -import org.sonar.api.utils.SonarException; - -import java.util.Arrays; - -import static org.fest.assertions.Assertions.assertThat; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; - -public class AnnotationCheckFactoryTest { - - @org.junit.Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void createCheckWithoutProperties() { - RulesProfile profile = RulesProfile.create("repo", "java"); - ActiveRule activeRule = profile.activateRule(Rule.create("repo", "org.sonar.api.checks.CheckWithoutProperties", ""), null); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithoutProperties.class)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertThat(check, is(CheckWithoutProperties.class)); - } - - @Test - public void createCheckWithStringProperty() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", ""); - rule.createParameter("pattern"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("pattern", "foo"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithStringProperty.class)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertThat(check, is(CheckWithStringProperty.class)); - assertThat(((CheckWithStringProperty) check).getPattern(), is("foo")); - } - - @Test - public void failIfMissingProperty() { - thrown.expect(SonarException.class); - - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", ""); - rule.createParameter("unknown"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("unknown", "bar"); - AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithStringProperty.class)); - } - - @Test - public void createCheckWithPrimitiveProperties() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithPrimitiveProperties", ""); - rule.createParameter("max"); - rule.createParameter("ignore"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - activeRule.setParameter("ignore", "true"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithPrimitiveProperties.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((CheckWithPrimitiveProperties) check).getMax(), is(300)); - assertThat(((CheckWithPrimitiveProperties) check).isIgnore(), is(true)); - } - - @Test - public void createCheckWithIntegerProperty() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithIntegerProperty", ""); - rule.createParameter("max"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithIntegerProperty.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((CheckWithIntegerProperty) check).getMax(), is(300)); - } - - /** - * SONAR-3164 - */ - @Test - public void setValueOfInheritedField() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.ImplementedCheck", ""); - rule.createParameter("max"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(ImplementedCheck.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((ImplementedCheck) check).getMax(), is(300)); - } - - @Test - public void failIfPropertyTypeIsNotSupported() { - thrown.expect(SonarException.class); - - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithUnsupportedPropertyType", ""); - rule.createParameter("max"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithUnsupportedPropertyType.class)); - } - - @Test - public void shouldOverridePropertyKey() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithOverriddenPropertyKey", ""); - rule.createParameter("maximum"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("maximum", "300"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithOverriddenPropertyKey.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((CheckWithOverriddenPropertyKey) check).getMax(), is(300)); - } - - @Test - public void shouldWorkWithClonedRules() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "CheckWithKey", ""); - Rule clonedRule = Rule.create("repo", "CheckWithKey_2", "").setConfigKey("CheckWithKey").setParent(rule); - - profile.activateRule(rule, null); - profile.activateRule(clonedRule, null); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithKey.class)); - - assertThat(factory.getChecks()).excludes(new Object[] {null}); - } - - /** - * SONAR-2900 - */ - @Test - public void create_accept_objects() { - RulesProfile profile = RulesProfile.create("repo", "java"); - ActiveRule activeRule = profile.activateRule(Rule.create("repo", "org.sonar.api.checks.CheckWithoutProperties", ""), null); - CheckWithoutProperties checkInstance = new CheckWithoutProperties(); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(checkInstance)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertSame(check, checkInstance); - } - - @Test - public void create_instance_with_string_property() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", ""); - rule.createParameter("pattern"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("pattern", "foo"); - CheckWithStringProperty checkInstance = new CheckWithStringProperty(); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(checkInstance)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertSame(check, checkInstance); - assertThat(checkInstance.getPattern(), is("foo")); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java deleted file mode 100644 index 60a4096940c..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.*; - -@Rule(priority = Priority.CRITICAL) -class CheckWithIntegerProperty { - - @RuleProperty - private Integer max; - - public Integer getMax() { - return max; - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java deleted file mode 100644 index 3b048a6b651..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; - -@Rule(key = "CheckWithKey", priority = Priority.CRITICAL) -public class CheckWithKey { - -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java deleted file mode 100644 index 868027f7a46..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithOverriddenPropertyKey{ - - @RuleProperty(key = "maximum") - private int max = 50; - - public int getMax() { - return max; - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java deleted file mode 100644 index 0d6a1d41c85..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithPrimitiveProperties { - - @RuleProperty(description = "Maximum threshold") - private int max = 50; - - @RuleProperty - private boolean ignore; - - public int getMax() { - return max; - } - - public boolean isIgnore() { - return ignore; - } -} - diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java deleted file mode 100644 index 6f10f76dec2..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithStringProperty { - - @RuleProperty - private String pattern; - - public String getPattern() { - return pattern; - } -} - diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java deleted file mode 100644 index 3401884e63d..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithUnsupportedPropertyType { - - @RuleProperty - private StringBuilder max = null; - -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java deleted file mode 100644 index aaa8f0b299d..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; - -@Rule(priority = Priority.CRITICAL) -class CheckWithoutProperties { - -} - diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java deleted file mode 100644 index 09c673570a2..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube 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. - * - * SonarQube 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 this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.api.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; - -@Rule(priority = Priority.CRITICAL) -class ImplementedCheck extends AbstractCheck { - -} |