From ee925d0a8d31556a37f98b6738e6f767b489e288 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 2 Oct 2014 23:09:52 +0200 Subject: Code clean-up * mark JFreechart as deprecated * complete some javadoc --- sonar-plugin-api/pom.xml | 4 - .../main/java/org/sonar/api/BatchComponent.java | 16 +- .../main/java/org/sonar/api/BatchExtension.java | 3 +- .../main/java/org/sonar/api/CoreProperties.java | 3 +- .../src/main/java/org/sonar/api/Extension.java | 2 +- .../src/main/java/org/sonar/api/Plugin.java | 5 +- .../src/main/java/org/sonar/api/Properties.java | 5 + .../src/main/java/org/sonar/api/Property.java | 11 +- .../main/java/org/sonar/api/ServerComponent.java | 3 +- .../src/main/java/org/sonar/api/SonarPlugin.java | 5 +- .../java/org/sonar/api/charts/AbstractChart.java | 97 ----------- .../src/main/java/org/sonar/api/charts/Chart.java | 41 ----- .../java/org/sonar/api/charts/ChartParameters.java | 184 --------------------- .../java/org/sonar/api/charts/package-info.java | 23 --- .../java/org/sonar/api/checks/NoSonarFilter.java | 67 -------- .../main/java/org/sonar/api/config/Category.java | 73 ++++++++ .../org/sonar/api/config/PropertyDefinitions.java | 2 - .../main/java/org/sonar/api/config/Settings.java | 2 +- .../java/org/sonar/api/config/SubCategory.java | 35 ++++ .../org/sonar/api/config/internal/Category.java | 73 -------- .../org/sonar/api/config/internal/SubCategory.java | 36 ---- .../sonar/api/config/internal/package-info.java | 23 --- .../org/sonar/api/charts/AbstractChartTest.java | 99 ----------- .../org/sonar/api/charts/ChartParametersTest.java | 78 --------- .../org/sonar/api/checks/NoSonarFilterTest.java | 80 --------- .../java/org/sonar/api/config/AesCipherTest.java | 1 - .../java/org/sonar/api/config/CategoryTest.java | 51 ++++++ .../sonar/api/config/PropertyDefinitionsTest.java | 2 - .../sonar/api/config/internal/CategoryTest.java | 51 ------ 29 files changed, 193 insertions(+), 882 deletions(-) delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/charts/Chart.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/charts/package-info.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/checks/NoSonarFilter.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java create mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/charts/AbstractChartTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/charts/ChartParametersTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java create mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java (limited to 'sonar-plugin-api') diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml index 44edf1918fd..6cdbdbde19f 100644 --- a/sonar-plugin-api/pom.xml +++ b/sonar-plugin-api/pom.xml @@ -84,10 +84,6 @@ commons-codec commons-codec - - jfree - jfreechart - org.slf4j slf4j-api diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/BatchComponent.java b/sonar-plugin-api/src/main/java/org/sonar/api/BatchComponent.java index 4ae6a337048..21c785caa1e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/BatchComponent.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/BatchComponent.java @@ -20,8 +20,20 @@ package org.sonar.api; /** - * Dependency Injection : all the classes implementing this interface are available in the batch IoC container. - * Just add a parameter to the constructor of your component. + * Marker interface for all the components available in container of batch (code analyzer). Note that + * injection of dependencies by constructor is used : + *
+ *   public class Foo implements BatchComponent {
+ *
+ *   }
+ *   public class Bar implements BatchComponent {
+ *     private final Foo foo;
+ *     public Bar(Foo f) {
+ *       this.foo = f;
+ *     }
+ *   }
+ *
+ * 
* * @since 2.2 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java b/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java index 6867cdd88b5..95cc1c0f8f7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java @@ -20,7 +20,8 @@ package org.sonar.api; /** - * Batch extension point. + * Marker interface for all the batch extension points, which are aimed to be implemented + * by plugins. * * @since 1.10 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java index 7016d777d8a..0705779f120 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java @@ -20,8 +20,7 @@ package org.sonar.api; /** - * CoreProperties is used to group various properties of Sonar as well - * as default values of configuration in a single place + * Non-exhaustive list of constants of core properties. * * @since 1.11 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java b/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java index a0ccc09fddc..1c5c8a52c07 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java @@ -20,7 +20,7 @@ package org.sonar.api; /** - * Extension point. + * Plugin extension point * * @since 1.10 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java b/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java index c0c1340b387..ea7bbc755e9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java @@ -22,10 +22,11 @@ package org.sonar.api; import java.util.List; /** - * A plugin is a group of extensions. See org.sonar.api.Extension interface to get all extension points. + * A plugin is a group of extensions. See org.sonar.api.Extension interface to browse + * available extension points. *

*

The manifest property Plugin-Class must declare the name of the implementation class. - * See META-INF/MANIFEST.MF.

+ * It is automatically set by sonar-packaging-maven-plugin when building plugins.

* * @see org.sonar.api.Extension * @since 1.10 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Properties.java b/sonar-plugin-api/src/main/java/org/sonar/api/Properties.java index 8191edf3319..c41c9f30958 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/Properties.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/Properties.java @@ -24,6 +24,11 @@ import java.lang.annotation.RetentionPolicy; /** * Plugin properties. This annotation is only used on classes implementing org.sonar.api.Plugin. + *

+ * Note that {@link org.sonar.api.config.PropertyDefinition} is an alternative, programmatic and recommended approach + * to declare properties. + *

+ * Effective property values are accessible at runtime through the component {@link org.sonar.api.config.Settings} * * @since 1.10 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Property.java b/sonar-plugin-api/src/main/java/org/sonar/api/Property.java index e9a6fdc50c5..5b0b10964d9 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/Property.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/Property.java @@ -28,18 +28,11 @@ import java.lang.annotation.Target; * Property value can be set in different ways : *

- *

- * Value is accessible in batch extensions via the Configuration object of class org.sonar.api.resources.Project - * (see method getConfiguration()). - *

- *

Must be used in org.sonar.api.Plugin classes only.

- *

- * It's recommended to use the class {@link org.sonar.api.config.PropertyDefinition} since v3.6. * * @since 1.10 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ServerComponent.java b/sonar-plugin-api/src/main/java/org/sonar/api/ServerComponent.java index e2f30ed3460..281c3058a7a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/ServerComponent.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/ServerComponent.java @@ -20,8 +20,7 @@ package org.sonar.api; /** - * Dependency Injection : all the classes implementing this interface are available in the server IoC container. - * Just add a parameter to the constructor of your component. + * Same than {@link org.sonar.api.BatchComponent} but for server-side components. * * @since 2.2 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/SonarPlugin.java b/sonar-plugin-api/src/main/java/org/sonar/api/SonarPlugin.java index 6e029ebcf96..c66422b6467 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/SonarPlugin.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/SonarPlugin.java @@ -20,7 +20,10 @@ package org.sonar.api; /** - * A plugin is a group of extensions. See {@link Extension} interface to get all extension points. + * Plugin entry-point used to declare its extensions (see {@link org.sonar.api.Extension}. + *

+ *

The JAR manifest must declare the name of the implementation class in the property Plugin-Class. + * This property is automatically set by sonar-packaging-maven-plugin when building plugin.

* * @since 2.8 */ diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java deleted file mode 100644 index b7e5006ad9d..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.charts; - -import org.jfree.chart.JFreeChart; -import org.jfree.chart.plot.CategoryPlot; -import org.jfree.chart.plot.Plot; -import org.jfree.chart.renderer.AbstractRenderer; -import org.jfree.chart.title.TextTitle; -import org.jfree.data.Values2D; - -import java.awt.Color; -import java.awt.image.BufferedImage; - -/** - * An extension point to generate JFreeChart charts - * - * @since 1.10 - */ -public abstract class AbstractChart implements Chart { - - public static final int FONT_SIZE = 13; - public static final Color OUTLINE_COLOR = new Color(51, 51, 51); - public static final Color GRID_COLOR = new Color(204, 204, 204); - public static final Color[] COLORS = new Color[] { Color.decode("#4192D9"), Color.decode("#800000"), Color.decode("#A7B307"), - Color.decode("#913C9F"), Color.decode("#329F4D") }; - - protected abstract Plot getPlot(ChartParameters params); - - protected boolean hasLegend() { - return false; - } - - /** - * Generates a JFreeChart chart using a set of parameters - * - * @param params the chart parameters - * @return the generated chart - */ - public BufferedImage generateImage(ChartParameters params) { - JFreeChart chart = new JFreeChart(null, TextTitle.DEFAULT_FONT, getPlot(params), hasLegend()); - improveChart(chart, params); - return chart.createBufferedImage(params.getWidth(), params.getHeight()); - } - - private void improveChart(JFreeChart jfrechart, ChartParameters params) { - Color background = Color.decode("#" + params.getValue(ChartParameters.PARAM_BACKGROUND_COLOR, "FFFFFF", false)); - jfrechart.setBackgroundPaint(background); - - jfrechart.setBorderVisible(false); - jfrechart.setAntiAlias(true); - jfrechart.setTextAntiAlias(true); - jfrechart.removeLegend(); - } - - @Override - public String toString() { - return getKey(); - } - - /** - * Helper to set color of series. If the parameter colorsHex is null, then default Sonar colors are used. - */ - protected void configureColors(Values2D dataset, CategoryPlot plot, String[] colorsHex) { - Color[] colors = COLORS; - if (colorsHex != null && colorsHex.length > 0) { - colors = new Color[colorsHex.length]; - for (int i = 0; i < colorsHex.length; i++) { - colors[i] = Color.decode("#" + colorsHex[i]); - } - } - - dataset.getColumnCount(); - AbstractRenderer renderer = (AbstractRenderer) plot.getRenderer(); - for (int i = 0; i < dataset.getColumnCount(); i++) { - renderer.setSeriesPaint(i, colors[i % colors.length]); - - } - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/charts/Chart.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/Chart.java deleted file mode 100644 index ac3080bfe8e..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/charts/Chart.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.charts; - -import org.sonar.api.ServerExtension; - -import java.awt.image.BufferedImage; - -/** - * An Extension to create charts - * - * @since 1.10 - */ -public interface Chart extends ServerExtension { - String getKey(); - - /** - * The method to implement to generate the chart - * - * @param params the chart parameters - * @return the image generated - */ - BufferedImage generateImage(ChartParameters params); -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java deleted file mode 100644 index 1f821aead01..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.charts; - -import org.apache.commons.lang.CharEncoding; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.text.StrTokenizer; -import org.sonar.api.utils.SonarException; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * The class to hold parameters to configure a chart - * @since 1.10 - */ -public class ChartParameters { - private static final String[] EMPTY = new String[0]; - - public static final String PARAM_WIDTH = "w"; - public static final String PARAM_BACKGROUND_COLOR = "bgc"; - public static final String PARAM_HEIGHT = "h"; - public static final int MAX_WIDTH = 900; - public static final String PARAM_LOCALE = "locale"; - - public static final int MAX_HEIGHT = 900; - public static final int DEFAULT_WIDTH = 200; - - public static final int DEFAULT_HEIGHT = 200; - - - private final Map params; - - /** - * Creates a ChartParameter based on a list of parameters - * @param params the list of parameters - */ - public ChartParameters(Map params) { - this.params = params; - } - - /** - * Creates a Chartparameter based on a query string with a format key1=value1&key2=value2... - * - * @param queryString string - */ - public ChartParameters(String queryString) { - this.params = new HashMap(); - String[] groups = StringUtils.split(queryString, "&"); - for (String group : groups) { - String[] keyval = StringUtils.split(group, "="); - params.put(keyval[0], keyval[1]); - } - } - - /** - * Shortcut to getValue with no decoding and no default value - * @param key the param ket - * @return the value of the param - */ - public String getValue(String key) { - return getValue(key, "", false); - } - - /** - * Returns the [decoded or not] value of a param from its key or the default value - * if id does not exist - * - * @param key the param ket - * @param defaultValue the default value if not exist - * @param decode whther the value should be decoded - * @return the value of the param - */ - - public String getValue(String key, String defaultValue, boolean decode) { - String val = params.get(key); - if (decode) { - val = decode(val); - } - if (val == null) { - val = defaultValue; - } - return val; - } - - /** - * Returns an array of a param values, given its key and the values delimiter - * - * @param key the param key - * @param delimiter the values delimiter - * @return the list of vaalues - */ - public String[] getValues(String key, String delimiter) { - String value = params.get(key); - if (value != null) { - return StringUtils.split(value, delimiter); - } - return EMPTY; - } - - /** - * Returns an array of a param values, given its key and the values delimiter - * Values can be decoded or not - * - * @param key the param key - * @param delimiter the values delimiter - * @param decode whether to decode values - * @return the list of vaalues - */ - public String[] getValues(String key, String delimiter, boolean decode) { - String value = params.get(key); - if (value != null) { - if (decode) { - value = decode(value); - } - return new StrTokenizer(value, delimiter).setIgnoreEmptyTokens(false).getTokenArray(); - } - return EMPTY; - } - - /** - * Get the chart width - * - * @return width - */ - public int getWidth() { - int width = Integer.parseInt(getValue(PARAM_WIDTH, "" + DEFAULT_WIDTH, false)); - return Math.min(width, MAX_WIDTH); - } - - /** - * Get the chart height - * - * @return height - */ - public int getHeight() { - int height = Integer.parseInt(getValue(PARAM_HEIGHT, "" + DEFAULT_HEIGHT, false)); - return Math.min(height, MAX_HEIGHT); - } - - /** - * Get the Locale - * - * @return Locale - */ - public Locale getLocale() { - String locale = getValue(PARAM_LOCALE); - if (StringUtils.isNotBlank(locale)) { - return new Locale(locale); - } - return Locale.ENGLISH; - } - - private String decode(String val) { - if (val != null) { - try { - val = URLDecoder.decode(val, CharEncoding.UTF_8); - } catch (UnsupportedEncodingException e) { - throw new SonarException("Decoding chart parameter : " + val, e); - } - } - return val; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/charts/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/package-info.java deleted file mode 100644 index 358d4bbef40..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/charts/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.api.charts; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/NoSonarFilter.java b/sonar-plugin-api/src/main/java/org/sonar/api/checks/NoSonarFilter.java deleted file mode 100644 index 05c4bd9bfaf..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/NoSonarFilter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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 com.google.common.collect.Maps; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.resources.Resource; -import org.sonar.api.rules.Violation; -import org.sonar.api.rules.ViolationFilter; - -import java.util.Map; -import java.util.Set; - -/** - * @since 2.1 - * @deprecated in 3.6. Replaced by {@link org.sonar.api.issue.NoSonarFilter} - */ -@Deprecated -public class NoSonarFilter implements ViolationFilter { - - private final Map> noSonarLinesByResource = Maps.newHashMap(); - private SensorContext context; - - public NoSonarFilter(SensorContext context) { - this.context = context; - } - - public void addResource(Resource model, Set noSonarLines) { - if (model != null && noSonarLines != null) { - // Reload resource to handle backward compatibility of resource keys - Resource resource = context.getResource(model); - if (resource != null) { - noSonarLinesByResource.put(resource, noSonarLines); - } - } - } - - public boolean isIgnored(Violation violation) { - boolean ignored = false; - if (violation.getResource() != null && violation.getLineId() != null) { - Set noSonarLines = noSonarLinesByResource.get(violation.getResource()); - ignored = noSonarLines != null && noSonarLines.contains(violation.getLineId()); - if (ignored && violation.getRule() != null && StringUtils.containsIgnoreCase(violation.getRule().getKey(), "nosonar")) { - ignored = false; - } - } - return ignored; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java new file mode 100644 index 00000000000..e4008f2ecea --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java @@ -0,0 +1,73 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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.config; + +import org.apache.commons.lang.StringUtils; + +import java.util.Locale; + +/** + * @since 3.7 + */ +class Category { + + private final String originalKey; + private final boolean special; + + Category(String originalKey) { + this(originalKey, false); + } + + Category(String originalKey, boolean special) { + this.originalKey = originalKey; + this.special = special; + } + + String originalKey() { + return originalKey; + } + + String key() { + return StringUtils.lowerCase(originalKey, Locale.ENGLISH); + } + + boolean isSpecial() { + return special; + } + + @Override + public int hashCode() { + return key().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Category)) { + return false; + } + return StringUtils.equalsIgnoreCase(((Category) obj).originalKey, this.originalKey); + } + + @Override + public String toString() { + return this.originalKey; + } + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java index 00b4af26138..5c20f786866 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java @@ -24,8 +24,6 @@ import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.sonar.api.*; import org.sonar.api.Properties; -import org.sonar.api.config.internal.Category; -import org.sonar.api.config.internal.SubCategory; import org.sonar.api.utils.AnnotationUtils; import javax.annotation.Nullable; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java index 3af2bacebd2..c243a1e7a6a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java @@ -39,7 +39,7 @@ import java.util.Map; import java.util.Properties; /** - * Project Settings on batch side, Global Settings on server side. This component does not access to database, so + * Project settings on batch side, or global settings on server side. This component does not access to database, so * property changed via setter methods are not persisted. *

*

diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java new file mode 100644 index 00000000000..05c96078eca --- /dev/null +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java @@ -0,0 +1,35 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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.config; + +/** + * @since 3.7 + */ +class SubCategory extends Category { + + SubCategory(String originalKey) { + super(originalKey); + } + + SubCategory(String originalKey, boolean special) { + super(originalKey, special); + } + +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java deleted file mode 100644 index c8990213204..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.config.internal; - -import org.apache.commons.lang.StringUtils; - -import java.util.Locale; - -/** - * @since 3.7 - */ -public class Category { - - private final String originalKey; - private final boolean special; - - public Category(String originalKey) { - this(originalKey, false); - } - - public Category(String originalKey, boolean special) { - this.originalKey = originalKey; - this.special = special; - } - - public String originalKey() { - return originalKey; - } - - public String key() { - return StringUtils.lowerCase(originalKey, Locale.ENGLISH); - } - - public boolean isSpecial() { - return special; - } - - @Override - public int hashCode() { - return key().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Category)) { - return false; - } - return StringUtils.equalsIgnoreCase(((Category) obj).originalKey, this.originalKey); - } - - @Override - public String toString() { - return this.originalKey; - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java deleted file mode 100644 index 8dfbcc16d10..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.config.internal; - - -/** - * @since 3.7 - */ -public class SubCategory extends Category { - - public SubCategory(String originalKey) { - super(originalKey); - } - - public SubCategory(String originalKey, boolean special) { - super(originalKey, special); - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java deleted file mode 100644 index 25458dc6179..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.api.config.internal; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/charts/AbstractChartTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/charts/AbstractChartTest.java deleted file mode 100644 index eba63156d5f..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/charts/AbstractChartTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.charts; - -import org.apache.commons.io.FileUtils; -import org.jfree.chart.ChartUtilities; -import org.jfree.ui.ApplicationFrame; -import org.jfree.ui.RefineryUtilities; - -import javax.swing.JPanel; - -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import static org.junit.Assert.assertTrue; - -public abstract class AbstractChartTest { - protected void assertChartSizeGreaterThan(BufferedImage img, int size) throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - ChartUtilities.writeBufferedImageAsPNG(output, img); - assertTrue("PNG size in bits=" + output.size(), output.size() > size); - } - - protected void assertChartSizeLesserThan(BufferedImage img, int size) throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - ChartUtilities.writeBufferedImageAsPNG(output, img); - assertTrue("PNG size in bits=" + output.size(), output.size() < size); - } - - protected void saveChart(BufferedImage img, String name) throws IOException { - File target = new File("target/tmp-chart", name); - FileUtils.forceMkdir(target.getParentFile()); - ByteArrayOutputStream imgOutput = new ByteArrayOutputStream(); - ChartUtilities.writeBufferedImageAsPNG(imgOutput, img); - OutputStream out = new FileOutputStream(target); - out.write(imgOutput.toByteArray()); - out.close(); - - } - - protected static void displayTestPanel(BufferedImage image) { - ApplicationFrame frame = new ApplicationFrame("testframe"); - BufferedPanel imgPanel = new BufferedPanel(image); - frame.setContentPane(imgPanel); - frame.pack(); - RefineryUtilities.centerFrameOnScreen(frame); - frame.setVisible(true); - } - - protected static Date stringToDate(String sDate) throws ParseException { - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy hh'h'mm"); - return sdf.parse(sDate); - } - - private static class BufferedPanel extends JPanel { - private final BufferedImage chartImage; - - public BufferedPanel(BufferedImage chartImage) { - this.chartImage = chartImage; - } - - @Override - protected void paintComponent(Graphics graphics) { - super.paintComponent(graphics); - graphics.drawImage(chartImage, 0, 0, null); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(chartImage.getWidth(), chartImage.getHeight()); - } - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/charts/ChartParametersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/charts/ChartParametersTest.java deleted file mode 100644 index 40fbe94c3b5..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/charts/ChartParametersTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.charts; - -import static org.junit.Assert.*; -import org.junit.Test; - -import java.util.Locale; - -public class ChartParametersTest { - @Test - public void shouldForbidHighSizeForSecurityReasons() { - String url = ChartParameters.PARAM_WIDTH + "=100000&" + ChartParameters.PARAM_HEIGHT + "=9999999"; - ChartParameters params = new ChartParameters(url); - assertEquals(ChartParameters.MAX_WIDTH, params.getWidth()); - assertEquals(ChartParameters.MAX_HEIGHT, params.getHeight()); - } - - @Test - public void shouldReadImageSizeFromParameters() { - String url = ChartParameters.PARAM_WIDTH + "=200&" + ChartParameters.PARAM_HEIGHT + "=300"; - ChartParameters params = new ChartParameters(url); - assertEquals(200, params.getWidth()); - assertEquals(300, params.getHeight()); - } - - @Test - public void shouldGetDefaultSizesIfNoParameters() { - ChartParameters params = new ChartParameters("foo=bar"); - assertEquals(ChartParameters.DEFAULT_WIDTH, params.getWidth()); - assertEquals(ChartParameters.DEFAULT_HEIGHT, params.getHeight()); - } - - @Test - public void shouldDecodeValue() { - ChartParameters params = new ChartParameters("foo=0%3D10,3%3D8"); - assertEquals("0=10,3=8", params.getValue("foo", "", true)); - assertEquals("0%3D10,3%3D8", params.getValue("foo")); - assertNull(params.getValue("bar", null, true)); - } - - @Test - public void shouldDecodeValues() { - ChartParameters params = new ChartParameters("foo=0%3D10,3%3D8|5%3D5,7%3D17"); - assertArrayEquals(new String[]{"0%3D10,3%3D8", "5%3D5,7%3D17"}, params.getValues("foo", "|")); - assertArrayEquals(new String[]{"0=10,3=8", "5=5,7=17"}, params.getValues("foo", "|", true)); - assertArrayEquals(new String[0], params.getValues("bar", "|", true)); - } - - @Test - public void getLocale() { - ChartParameters params = new ChartParameters("foo=0&locale=fr"); - assertEquals(Locale.FRENCH, params.getLocale()); - - params = new ChartParameters("foo=0&locale=fr-CH"); - assertEquals("fr-ch", params.getLocale().getLanguage()); - - params = new ChartParameters("foo=0"); - assertEquals(Locale.ENGLISH, params.getLocale()); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java deleted file mode 100644 index 7f4793b77cd..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.Before; -import org.junit.Test; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.resources.File; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.Violation; - -import java.util.HashSet; -import java.util.Set; - -import static org.fest.assertions.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class NoSonarFilterTest { - - private SensorContext sensorContext = mock(SensorContext.class); - NoSonarFilter filter = new NoSonarFilter(sensorContext); - private File javaFile; - - @Before - public void prepare() { - javaFile = new File("org.foo.Bar"); - when(sensorContext.getResource(javaFile)).thenReturn(javaFile); - } - - @Test - public void ignoreLinesCommentedWithNoSonar() { - Set noSonarLines = new HashSet(); - noSonarLines.add(31); - noSonarLines.add(55); - filter.addResource(javaFile, noSonarLines); - - // violation on class - assertThat(filter.isIgnored(new Violation(null, javaFile))).isFalse(); - - // violation on lines - assertThat(filter.isIgnored(new Violation(null, javaFile).setLineId(30))).isFalse(); - assertThat(filter.isIgnored(new Violation(null, javaFile).setLineId(31))).isTrue(); - } - - @Test - public void doNotIgnoreWhenNotFoundInSquid() { - assertThat(filter.isIgnored(new Violation(null, javaFile).setLineId(30))).isFalse(); - } - - @Test - public void should_accept_violations_from_no_sonar_rules() throws Exception { - // The "No Sonar" rule logs violations on the lines that are flagged with "NOSONAR" !! - - Set noSonarLines = new HashSet(); - noSonarLines.add(31); - filter.addResource(javaFile, noSonarLines); - - Rule noSonarRule = new Rule("squid", "NoSonarCheck"); - assertThat(filter.isIgnored(new Violation(noSonarRule, javaFile).setLineId(31))).isFalse(); - - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java index 7631b6b9b85..b2dccf589b3 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java @@ -36,7 +36,6 @@ import java.security.Key; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.Is.isA; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java new file mode 100644 index 00000000000..c6d9f3a733b --- /dev/null +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/CategoryTest.java @@ -0,0 +1,51 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 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.config; + +import org.junit.Test; + +import static org.fest.assertions.Assertions.assertThat; + +public class CategoryTest { + + @Test + public void category_key_is_case_insentive() { + assertThat(new Category("Licenses")).isEqualTo(new Category("licenses")); + + // Just to raise coverage + assertThat(new Category("Licenses")).isNotEqualTo("Licenses"); + } + + @Test + public void should_preserve_original_key() { + assertThat(new Category("Licenses").originalKey()).isEqualTo("Licenses"); + } + + @Test + public void should_normalize_key() throws Exception { + assertThat(new Category("Licenses").key()).isEqualTo("licenses"); + } + + @Test + public void should_use_original_key() throws Exception { + assertThat(new Category("Licenses").toString()).isEqualTo("Licenses"); + } + +} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java index 4a43b55d1a2..333b8e15c3e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java @@ -22,8 +22,6 @@ package org.sonar.api.config; import org.junit.Test; import org.sonar.api.Properties; import org.sonar.api.Property; -import org.sonar.api.config.internal.Category; -import org.sonar.api.config.internal.SubCategory; import org.sonar.api.resources.Qualifiers; import java.util.Arrays; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java deleted file mode 100644 index 1c325e5eceb..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/internal/CategoryTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 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.config.internal; - -import org.junit.Test; - -import static org.fest.assertions.Assertions.assertThat; - -public class CategoryTest { - - @Test - public void category_key_is_case_insentive() { - assertThat(new Category("Licenses")).isEqualTo(new Category("licenses")); - - // Just to raise coverage - assertThat(new Category("Licenses")).isNotEqualTo("Licenses"); - } - - @Test - public void should_preserve_original_key() { - assertThat(new Category("Licenses").originalKey()).isEqualTo("Licenses"); - } - - @Test - public void should_normalize_key() throws Exception { - assertThat(new Category("Licenses").key()).isEqualTo("licenses"); - } - - @Test - public void should_use_original_key() throws Exception { - assertThat(new Category("Licenses").toString()).isEqualTo("Licenses"); - } - -} -- cgit v1.2.3