From b34848e03a03be1d8960c885a8b43518f4d9946c Mon Sep 17 00:00:00 2001 From: Daniel Muehlbachler-Pietrzykowski Date: Fri, 1 Mar 2024 13:05:19 +0100 Subject: [PATCH] Issue #502: update to LTS 9.9; cleanup deprecations --- config/sevntu-suppressions.xml | 3 - config/suppressions.xml | 2 - pom.xml | 27 +- .../checkstyle/CheckstyleAuditListener.java | 2 +- .../checkstyle/CheckstyleConfiguration.java | 13 +- .../checkstyle/CheckstyleExecutor.java | 13 +- .../plugins/checkstyle/CheckstylePlugin.java | 7 +- .../checkstyle/CheckstyleProfileExporter.java | 92 +++---- .../checkstyle/CheckstyleProfileImporter.java | 218 ---------------- .../checkstyle/CheckstyleRulesDefinition.java | 2 +- .../checkstyle/CheckstyleSeverityUtils.java | 37 --- .../checkstyle/rule/ActiveRuleWrapper.java | 45 ---- .../rule/ActiveRuleWrapperScannerImpl.java | 61 ----- .../rule/ActiveRuleWrapperServerImpl.java | 76 ------ .../plugins/checkstyle/rule/package-info.java | 27 -- .../CheckstyleConfigurationTest.java | 2 +- .../checkstyle/CheckstyleExecutorTest.java | 26 +- .../checkstyle/CheckstylePluginTest.java | 2 +- .../CheckstyleProfileExporterTest.java | 135 ++-------- .../CheckstyleProfileImporterTest.java | 237 ------------------ .../CheckstyleRulesDefinitionTest.java | 5 - .../CheckstyleSeverityUtilsTest.java | 19 -- .../addCustomFilters.xml | 11 +- .../addCustomTreewalkerFilters.xml | 8 +- .../addTabWidthProperty.xml | 20 +- ...yWhenManyInstancesWithTheSameConfigKey.xml | 16 -- .../alwaysSetSuppressionCommentFilter.xml | 9 - .../exportParameters.xml | 13 - .../noCheckstyleRulesToExport.xml | 9 - .../singleCheckstyleActiveRulesToExport.xml | 5 +- .../singleCheckstyleRulesToExport.xml | 15 -- .../idPropertyShouldBeTheRuleKey.xml | 11 - .../importingFiltersIsNotSupported.xml | 13 - .../inheritance_of_properties.xml | 7 - .../shouldUseTheIdPropertyToFindRule.xml | 11 - .../CheckstyleProfileImporterTest/simple.xml | 13 - 36 files changed, 113 insertions(+), 1099 deletions(-) delete mode 100644 src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java delete mode 100644 src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java delete mode 100644 src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java delete mode 100644 src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java delete mode 100644 src/main/java/org/sonar/plugins/checkstyle/rule/package-info.java delete mode 100644 src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTheIdPropertyWhenManyInstancesWithTheSameConfigKey.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/alwaysSetSuppressionCommentFilter.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/exportParameters.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/noCheckstyleRulesToExport.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleRulesToExport.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/idPropertyShouldBeTheRuleKey.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/importingFiltersIsNotSupported.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/inheritance_of_properties.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/shouldUseTheIdPropertyToFindRule.xml delete mode 100644 src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/simple.xml diff --git a/config/sevntu-suppressions.xml b/config/sevntu-suppressions.xml index 9738511d..72a0e059 100644 --- a/config/sevntu-suppressions.xml +++ b/config/sevntu-suppressions.xml @@ -13,9 +13,6 @@ - - - diff --git a/config/suppressions.xml b/config/suppressions.xml index 9fd3ab9a..640fc65c 100644 --- a/config/suppressions.xml +++ b/config/suppressions.xml @@ -11,8 +11,6 @@ - - diff --git a/pom.xml b/pom.xml index 85e84fd7..1832e6ae 100644 --- a/pom.xml +++ b/pom.xml @@ -94,8 +94,8 @@ 10.12.5 - 8.9.0.43852 - 7.2.0.26923 + 9.9.4.87374 + 9.9.0.229 1.44.1 @@ -158,9 +158,9 @@ 32.0.0-jre - org.sonarsource.sonarqube + org.sonarsource.api.plugin sonar-plugin-api - ${sonar.version} + ${sonar.api-version} provided @@ -573,7 +573,6 @@ org.sonar.plugins.checkstyle.CheckstyleExecutor org.sonar.plugins.checkstyle.CheckstyleSeverityUtils org.sonar.plugins.checkstyle.CheckstyleConfiguration - org.sonar.plugins.checkstyle.CheckstyleProfileImporter org.sonar.plugins.checkstyle.CheckstyleRulesDefinition org.sonar.plugins.checkstyle.metadata.CheckstyleMetadata org.sonar.plugins.checkstyle.metadata.CheckUtil @@ -682,24 +681,6 @@ - - CLASS - - org.sonar.plugins.checkstyle.CheckstyleProfileImporter - - - - LINE - COVEREDRATIO - 1.0 - - - BRANCH - COVEREDRATIO - 0.96 - - - CLASS diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleAuditListener.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleAuditListener.java index 175c3c99..b3827b5c 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleAuditListener.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleAuditListener.java @@ -25,7 +25,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.ExtensionPoint; -import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.rule.ActiveRule; @@ -34,6 +33,7 @@ import org.sonar.api.batch.sensor.issue.NewIssue; import org.sonar.api.batch.sensor.issue.NewIssueLocation; import org.sonar.api.rule.RuleKey; +import org.sonar.api.scanner.ScannerSide; import com.google.common.annotations.VisibleForTesting; import com.puppycrawl.tools.checkstyle.api.AuditEvent; diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java index 563041fe..cbd38a44 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleConfiguration.java @@ -33,11 +33,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.ExtensionPoint; -import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.fs.FilePredicates; import org.sonar.api.batch.fs.FileSystem; import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.rule.ActiveRules; +import org.sonar.api.scanner.ScannerSide; import com.google.common.annotations.VisibleForTesting; import com.puppycrawl.tools.checkstyle.ConfigurationLoader; @@ -59,6 +59,17 @@ public class CheckstyleConfiguration { private final FileSystem fileSystem; public CheckstyleConfiguration( + org.sonar.api.config.Configuration conf, + ActiveRules activeRules, + FileSystem fileSystem) { + this.conf = conf; + this.confExporter = new CheckstyleProfileExporter(conf); + this.activeRules = activeRules; + this.fileSystem = fileSystem; + } + + // used for unit testing + protected CheckstyleConfiguration( org.sonar.api.config.Configuration conf, CheckstyleProfileExporter confExporter, ActiveRules activeRules, diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleExecutor.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleExecutor.java index 2d138a1f..4b0a98e5 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleExecutor.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleExecutor.java @@ -34,15 +34,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.ExtensionPoint; -import org.sonar.api.batch.ScannerSide; -import org.sonar.api.batch.fs.InputFile; import org.sonar.api.batch.sensor.SensorContext; +import org.sonar.api.scanner.ScannerSide; import com.google.common.annotations.VisibleForTesting; +import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean; import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.PackageNamesLoader; import com.puppycrawl.tools.checkstyle.XMLLogger; -import com.puppycrawl.tools.checkstyle.api.AutomaticBean; @ExtensionPoint @ScannerSide @@ -98,16 +97,16 @@ private void executeWithClassLoader() { LOG.info("Checkstyle output report: {}", xmlReport.getAbsolutePath()); xmlOutput = FileUtils.openOutputStream(xmlReport); checker.addListener( - new XMLLogger(xmlOutput, AutomaticBean.OutputStreamOptions.CLOSE)); + new XMLLogger(xmlOutput, AbstractAutomaticBean.OutputStreamOptions.CLOSE)); } checker.setCharset(configuration.getCharset().name()); checker.configure(configuration.getCheckstyleConfiguration()); checker.process(configuration .getSourceFiles() - .stream() - .map(InputFile::file) - .collect(Collectors.toList())); + .stream() + .map(inputFile -> new File(inputFile.uri())) + .collect(Collectors.toList())); } catch (Exception ex) { throw new IllegalStateException("Can not execute Checkstyle", ex); diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java index 84764344..fd05c3bf 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java @@ -76,7 +76,7 @@ public static List getExtensions() { .name("Checker Filters") .description(CHECKER_FILTERS_DESCRIPTION) .type(PropertyType.TEXT) - .onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(), + .onQualifiers(Qualifiers.PROJECT, Qualifiers.PROJECT).build(), PropertyDefinition.builder(CheckstyleConstants.TREEWALKER_FILTERS_KEY) .defaultValue(CheckstyleConstants.TREEWALKER_FILTERS_DEFAULT_VALUE) .category(CHECKSTYLE_CATEGORY_NAME) @@ -84,14 +84,14 @@ public static List getExtensions() { .name("Treewalker Filters") .description(TREEWALKER_FILTERS_DESCRIPTION) .type(PropertyType.TEXT) - .onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE).build(), + .onQualifiers(Qualifiers.PROJECT, Qualifiers.PROJECT).build(), PropertyDefinition.builder(CheckstyleConstants.CHECKER_TAB_WIDTH) .category(CHECKSTYLE_CATEGORY_NAME) .subCategory(CHECKSTYLE_SUB_CATEGORY_NAME) .name("Tab Width") .description(CHECKER_TAB_WIDTH_DESCRIPTION) .type(PropertyType.INTEGER) - .onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE) + .onQualifiers(Qualifiers.PROJECT, Qualifiers.PROJECT) .build(), PropertyDefinition.builder(CheckstyleConfiguration.PROPERTY_GENERATE_XML) .defaultValue("false").category(CHECKSTYLE_CATEGORY_NAME) @@ -101,7 +101,6 @@ public static List getExtensions() { CheckstyleSensor.class, CheckstyleConfiguration.class, CheckstyleExecutor.class, CheckstyleAuditListener.class, - CheckstyleProfileExporter.class, CheckstyleProfileImporter.class, CheckstyleRulesDefinition.class); } diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java index de139a36..9923558d 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporter.java @@ -32,22 +32,13 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; -import org.sonar.api.ExtensionPoint; -import org.sonar.api.batch.ScannerSide; +import org.sonar.api.batch.rule.ActiveRule; import org.sonar.api.batch.rule.ActiveRules; import org.sonar.api.config.Configuration; -import org.sonar.api.profiles.ProfileExporter; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; -import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapper; -import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperScannerImpl; -import org.sonar.plugins.checkstyle.rule.ActiveRuleWrapperServerImpl; import com.google.common.annotations.VisibleForTesting; -@ExtensionPoint -@ScannerSide -public class CheckstyleProfileExporter extends ProfileExporter { +public class CheckstyleProfileExporter { public static final String DOCTYPE_DECLARATION = " activeRules = profile - .getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY); - if (activeRules != null) { - final List activeRuleWrappers = new ArrayList<>(); - for (ActiveRule activeRule : activeRules) { - activeRuleWrappers.add(new ActiveRuleWrapperServerImpl(activeRule)); - } - final Map> activeRulesByConfigKey = - arrangeByConfigKey(activeRuleWrappers); - generateXml(writer, activeRulesByConfigKey); - } - } - catch (IOException ex) { - throw new IllegalStateException("Fail to export the profile " + profile, ex); - } } /** @@ -92,13 +60,9 @@ public void exportProfile(RulesProfile profile, Writer writer) { */ public void exportProfile(ActiveRules activeRules, Writer writer) { try { - final List activeRuleWrappers = new ArrayList<>(); - for (org.sonar.api.batch.rule.ActiveRule activeRule : activeRules - .findByRepository(CheckstyleConstants.REPOSITORY_KEY)) { - activeRuleWrappers.add(new ActiveRuleWrapperScannerImpl(activeRule)); - } - final Map> activeRulesByConfigKey = - arrangeByConfigKey(activeRuleWrappers); + final Map> activeRulesByConfigKey = + arrangeByConfigKey(activeRules + .findByRepository(CheckstyleConstants.REPOSITORY_KEY)); generateXml(writer, activeRulesByConfigKey); } catch (IOException ex) { @@ -108,7 +72,7 @@ public void exportProfile(ActiveRules activeRules, Writer writer) { } private void generateXml(Writer writer, Map> activeRulesByConfigKey) throws IOException { + List> activeRulesByConfigKey) throws IOException { appendXmlHeader(writer); appendTabWidth(writer); appendCustomFilters(writer); @@ -135,12 +99,12 @@ private void appendTabWidth(Writer writer) throws IOException { } private static void appendCheckerModules(Writer writer, - Map> activeRulesByConfigKey) throws IOException { - for (Map.Entry> entry : activeRulesByConfigKey.entrySet()) { + Map> activeRulesByConfigKey) throws IOException { + for (Map.Entry> entry : activeRulesByConfigKey.entrySet()) { final String configKey = entry.getKey(); if (!isInTreeWalker(configKey)) { - final List activeRules = entry.getValue(); - for (ActiveRuleWrapper activeRule : activeRules) { + final List activeRules = entry.getValue(); + for (ActiveRule activeRule : activeRules) { appendModule(writer, activeRule); } } @@ -148,7 +112,7 @@ private static void appendCheckerModules(Writer writer, } private void appendTreeWalker(Writer writer, - Map> activeRulesByConfigKey) throws IOException { + Map> activeRulesByConfigKey) throws IOException { writer.append(""); if (isSuppressWarningsEnabled()) { writer.append(" "); @@ -157,8 +121,8 @@ private void appendTreeWalker(Writer writer, Collections.sort(ruleSet); for (String configKey : ruleSet) { if (isInTreeWalker(configKey)) { - final List activeRules = activeRulesByConfigKey.get(configKey); - for (ActiveRuleWrapper activeRule : activeRules) { + final List activeRules = activeRulesByConfigKey.get(configKey); + for (ActiveRule activeRule : activeRules) { appendModule(writer, activeRule); } } @@ -191,17 +155,17 @@ static boolean isInTreeWalker(String configKey) { return StringUtils.startsWithIgnoreCase(configKey, "Checker/TreeWalker/"); } - private static Map> arrangeByConfigKey( - Collection activeRules) { - final Map> result = new HashMap<>(); - for (ActiveRuleWrapper activeRule : activeRules) { - final String key = activeRule.getInternalKey(); + private static Map> arrangeByConfigKey( + Collection activeRules) { + final Map> result = new HashMap<>(); + for (ActiveRule activeRule : activeRules) { + final String key = activeRule.internalKey(); if (result.containsKey(key)) { - final List rules = result.get(key); + final List rules = result.get(key); rules.add(activeRule); } else { - final List rules = new ArrayList<>(); + final List rules = new ArrayList<>(); rules.add(activeRule); result.put(key, rules); } @@ -209,23 +173,25 @@ private static Map> arrangeByConfigKey( return result; } - private static void appendModule(Writer writer, ActiveRuleWrapper activeRule) + private static void appendModule(Writer writer, ActiveRule activeRule) throws IOException { - final String moduleName = StringUtils.substringAfterLast(activeRule.getInternalKey(), "/"); + final String moduleName = StringUtils.substringAfterLast(activeRule.internalKey(), "/"); writer.append(""); - if (activeRule.getTemplateRuleKey() != null) { - appendModuleProperty(writer, "id", activeRule.getRuleKey()); + if (activeRule.templateRuleKey() != null) { + appendModuleProperty(writer, "id", + activeRule.ruleKey().rule()); } - appendModuleProperty(writer, "severity", activeRule.getSeverity()); + appendModuleProperty(writer, "severity", + CheckstyleSeverityUtils.toSeverity(activeRule.severity())); appendRuleParameters(writer, activeRule); writer.append(CLOSE_MODULE); } - private static void appendRuleParameters(Writer writer, ActiveRuleWrapper activeRule) + private static void appendRuleParameters(Writer writer, ActiveRule activeRule) throws IOException { - for (Map.Entry param : activeRule.getParams().entrySet()) { + for (Map.Entry param : activeRule.params().entrySet()) { if (StringUtils.isNotBlank(param.getValue())) { appendModuleProperty(writer, param.getKey(), param.getValue()); } diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java deleted file mode 100644 index a2af3021..00000000 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java +++ /dev/null @@ -1,218 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// checkstyle: Checks Java source code for adherence to a set of rules. -// Copyright (C) 2001-2024 the original author or authors. -// -// This library 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. -// -// This library 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 library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//////////////////////////////////////////////////////////////////////////////// - -package org.sonar.plugins.checkstyle; - -import java.io.Reader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; - -import org.apache.commons.lang.StringUtils; -import org.codehaus.staxmate.SMInputFactory; -import org.codehaus.staxmate.in.SMInputCursor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonar.api.ExtensionPoint; -import org.sonar.api.batch.ScannerSide; -import org.sonar.api.profiles.ProfileImporter; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RuleFinder; -import org.sonar.api.rules.RuleQuery; -import org.sonar.api.utils.ValidationMessages; - -import com.google.common.annotations.VisibleForTesting; - -@ExtensionPoint -@ScannerSide -public class CheckstyleProfileImporter extends ProfileImporter { - - private static final Logger LOG = LoggerFactory.getLogger(CheckstyleProfileImporter.class); - - private static final String CHECKER_MODULE = "Checker"; - private static final String TREEWALKER_MODULE = "TreeWalker"; - private static final String MODULE_NODE = "module"; - private static final String[] FILTERS = { - "SeverityMatchFilter", - "SuppressionFilter", - "SuppressWarningsFilter", - "SuppressionCommentFilter", - "SuppressWithNearbyCommentFilter", - "SuppressionXpathSingleFilter", - "SuppressionSingleFilter", - }; - private final RuleFinder ruleFinder; - - public CheckstyleProfileImporter(RuleFinder ruleFinder) { - super(CheckstyleConstants.REPOSITORY_KEY, CheckstyleConstants.PLUGIN_NAME); - setSupportedLanguages(CheckstyleConstants.JAVA_KEY); - this.ruleFinder = ruleFinder; - } - - private Module loadModule(SMInputCursor parentCursor) throws XMLStreamException { - final Module result = new Module(); - result.name = parentCursor.getAttrValue("name"); - final SMInputCursor cursor = parentCursor.childElementCursor(); - while (cursor.getNext() != null) { - final String nodeName = cursor.getLocalName(); - if (MODULE_NODE.equals(nodeName)) { - result.modules.add(loadModule(cursor)); - } - else if ("property".equals(nodeName)) { - final String key = cursor.getAttrValue("name"); - final String value = cursor.getAttrValue("value"); - result.properties.put(key, value); - } - } - return result; - } - - @Override - public RulesProfile importProfile(Reader reader, ValidationMessages messages) { - final SMInputFactory inputFactory = initStax(); - final RulesProfile profile = RulesProfile.create(); - try { - final Module checkerModule = loadModule(inputFactory.rootElementCursor(reader) - .advance()); - - for (Module rootModule : checkerModule.modules) { - final Map rootModuleProperties = new HashMap<>( - checkerModule.properties); - rootModuleProperties.putAll(rootModule.properties); - - if (StringUtils.equals(TREEWALKER_MODULE, rootModule.name)) { - processTreewalker(profile, rootModule, rootModuleProperties, messages); - } - else { - processModule(profile, CHECKER_MODULE + "/", rootModule.name, - rootModuleProperties, messages); - } - } - - } - catch (XMLStreamException ex) { - final String message = "XML is not valid: " + ex.getMessage(); - LOG.error(message, ex); - messages.addErrorText(message); - } - return profile; - } - - private void processTreewalker(RulesProfile profile, Module rootModule, - Map rootModuleProperties, ValidationMessages messages) { - for (Module treewalkerModule : rootModule.modules) { - final Map treewalkerModuleProperties = new HashMap<>( - rootModuleProperties); - treewalkerModuleProperties.putAll(treewalkerModule.properties); - - processModule(profile, CHECKER_MODULE + "/" + TREEWALKER_MODULE + "/", - treewalkerModule.name, treewalkerModuleProperties, messages); - } - } - - private static SMInputFactory initStax() { - final XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); - xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); - xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); - xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); - xmlFactory.setProperty(XMLInputFactory.IS_VALIDATING, Boolean.FALSE); - return new SMInputFactory(xmlFactory); - } - - private void processModule(RulesProfile profile, String path, String moduleName, - Map properties, ValidationMessages messages) { - if (isFilter(moduleName)) { - messages.addWarningText("Checkstyle filters are not imported: " + moduleName); - - } - else if (!isIgnored(moduleName)) { - processRule(profile, path, moduleName, properties, messages); - } - } - - @VisibleForTesting - static boolean isIgnored(String configKey) { - return StringUtils.equals(configKey, "SuppressWarningsHolder"); - } - - @VisibleForTesting - static boolean isFilter(String configKey) { - boolean result = false; - for (String filter : FILTERS) { - if (StringUtils.equals(configKey, filter)) { - result = true; - break; - } - } - return result; - } - - private void processRule(RulesProfile profile, String path, String moduleName, - Map properties, ValidationMessages messages) { - final Rule rule; - final String id = properties.get("id"); - final String warning; - if (StringUtils.isNotBlank(id)) { - rule = ruleFinder.find(RuleQuery.create() - .withRepositoryKey(CheckstyleConstants.REPOSITORY_KEY).withKey(id)); - warning = "Checkstyle rule with key '" + id + "' not found"; - - } - else { - final String configKey = path + moduleName; - rule = ruleFinder - .find(RuleQuery.create().withRepositoryKey(CheckstyleConstants.REPOSITORY_KEY) - .withConfigKey(configKey)); - warning = "Checkstyle rule with config key '" + configKey + "' not found"; - } - - if (rule == null) { - messages.addWarningText(warning); - - } - else { - final ActiveRule activeRule = profile.activateRule(rule, null); - activateProperties(activeRule, properties); - } - } - - private static void activateProperties(ActiveRule activeRule, Map properties) { - for (Map.Entry property : properties.entrySet()) { - if (StringUtils.equals("severity", property.getKey())) { - activeRule.setSeverity(CheckstyleSeverityUtils.fromSeverity(property.getValue())); - - } - else if (!StringUtils.equals("id", property.getKey())) { - activeRule.setParameter(property.getKey(), property.getValue()); - } - } - } - - private static final class Module { - private final Map properties = new HashMap<>(); - private final List modules = new ArrayList<>(); - private String name; - } -} diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinition.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinition.java index 5b5b6cff..93aad5a7 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinition.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinition.java @@ -20,7 +20,7 @@ package org.sonar.plugins.checkstyle; import org.sonar.api.ExtensionPoint; -import org.sonar.api.batch.ScannerSide; +import org.sonar.api.scanner.ScannerSide; import org.sonar.api.server.rule.RulesDefinition; import org.sonar.plugins.checkstyle.metadata.CheckstyleMetadata; diff --git a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java index b815d6c2..d9f8ee08 100644 --- a/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java +++ b/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtils.java @@ -19,24 +19,14 @@ package org.sonar.plugins.checkstyle; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonar.api.rules.RulePriority; - import com.puppycrawl.tools.checkstyle.api.SeverityLevel; public final class CheckstyleSeverityUtils { - private static final Logger LOG = LoggerFactory.getLogger(CheckstyleSeverityUtils.class); - private CheckstyleSeverityUtils() { // only static methods } - public static String toSeverity(RulePriority priority) { - return toSeverity(priority.name()); - } - public static String toSeverity(String priority) { final String result; @@ -58,31 +48,4 @@ public static String toSeverity(String priority) { return result; } - - public static RulePriority fromSeverity(String severity) { - RulePriority result = null; - - try { - final SeverityLevel severityLevel = SeverityLevel.getInstance(severity); - - switch (severityLevel) { - case ERROR: - result = RulePriority.BLOCKER; - break; - case WARNING: - result = RulePriority.MAJOR; - break; - case INFO: - case IGNORE: - result = RulePriority.INFO; - break; - default: - } - } - catch (Exception exc) { - LOG.warn("Smth wrong severity", exc); - } - - return result; - } } diff --git a/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java b/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java deleted file mode 100644 index 28512868..00000000 --- a/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapper.java +++ /dev/null @@ -1,45 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// checkstyle: Checks Java source code for adherence to a set of rules. -// Copyright (C) 2001-2024 the original author or authors. -// -// This library 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. -// -// This library 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 library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//////////////////////////////////////////////////////////////////////////////// - -package org.sonar.plugins.checkstyle.rule; - -import java.util.Map; - -/** - * Due to our usage of {@link org.sonar.plugins.checkstyle.CheckstyleProfileExporter} - * on the {@link org.sonar.api.batch.ScannerSide} for generating CheckStyle configurations, - * we must make it compatible for the new {@link org.sonar.api.batch.rule.ActiveRules}. - * - *

- * Hence, to gain compatibility with server and scanner side in the exporter, - * we have to wrap either {@link org.sonar.api.batch.rule.ActiveRule} or - * {@link org.sonar.api.rules.ActiveRule} for usage in the exporter. - *

- */ -public interface ActiveRuleWrapper { - String getInternalKey(); - - String getRuleKey(); - - String getTemplateRuleKey(); - - String getSeverity(); - - Map getParams(); -} diff --git a/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java b/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java deleted file mode 100644 index f8e0c44e..00000000 --- a/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperScannerImpl.java +++ /dev/null @@ -1,61 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// checkstyle: Checks Java source code for adherence to a set of rules. -// Copyright (C) 2001-2024 the original author or authors. -// -// This library 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. -// -// This library 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 library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//////////////////////////////////////////////////////////////////////////////// - -package org.sonar.plugins.checkstyle.rule; - -import java.util.Map; - -import org.sonar.api.batch.rule.ActiveRule; -import org.sonar.plugins.checkstyle.CheckstyleSeverityUtils; - -/** - * Wrapper as per {@link ActiveRuleWrapper} for the new scanner side {@link ActiveRule}. - */ -public class ActiveRuleWrapperScannerImpl implements ActiveRuleWrapper { - private final ActiveRule activeRule; - - public ActiveRuleWrapperScannerImpl(ActiveRule activeRule) { - this.activeRule = activeRule; - } - - @Override - public String getInternalKey() { - return activeRule.internalKey(); - } - - @Override - public String getRuleKey() { - return activeRule.ruleKey().rule(); - } - - @Override - public String getTemplateRuleKey() { - return activeRule.templateRuleKey(); - } - - @Override - public String getSeverity() { - return CheckstyleSeverityUtils.toSeverity(activeRule.severity()); - } - - @Override - public Map getParams() { - return activeRule.params(); - } -} diff --git a/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java b/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java deleted file mode 100644 index 38534534..00000000 --- a/src/main/java/org/sonar/plugins/checkstyle/rule/ActiveRuleWrapperServerImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// checkstyle: Checks Java source code for adherence to a set of rules. -// Copyright (C) 2001-2024 the original author or authors. -// -// This library 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. -// -// This library 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 library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//////////////////////////////////////////////////////////////////////////////// - -package org.sonar.plugins.checkstyle.rule; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import org.apache.commons.lang.StringUtils; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.RuleParam; -import org.sonar.plugins.checkstyle.CheckstyleSeverityUtils; - -/** - * Wrapper as per {@link ActiveRuleWrapper} for the server side {@link ActiveRule}. - */ -public class ActiveRuleWrapperServerImpl implements ActiveRuleWrapper { - private final ActiveRule activeRule; - - public ActiveRuleWrapperServerImpl(ActiveRule activeRule) { - this.activeRule = activeRule; - } - - @Override - public String getInternalKey() { - return activeRule.getConfigKey(); - } - - @Override - public String getRuleKey() { - return activeRule.getRuleKey(); - } - - @Override - public String getTemplateRuleKey() { - String result = null; - if (Objects.nonNull(activeRule.getRule().getTemplate())) { - result = activeRule.getRule().getTemplate().getKey(); - } - return result; - } - - @Override - public String getSeverity() { - return CheckstyleSeverityUtils.toSeverity(activeRule.getSeverity()); - } - - @Override - public Map getParams() { - final Map result = new HashMap<>(); - for (RuleParam param : activeRule.getRule().getParams()) { - final String value = activeRule.getParameter(param.getKey()); - if (StringUtils.isNotBlank(value)) { - result.put(param.getKey(), value); - } - } - return result; - } -} diff --git a/src/main/java/org/sonar/plugins/checkstyle/rule/package-info.java b/src/main/java/org/sonar/plugins/checkstyle/rule/package-info.java deleted file mode 100644 index 007648a1..00000000 --- a/src/main/java/org/sonar/plugins/checkstyle/rule/package-info.java +++ /dev/null @@ -1,27 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// checkstyle: Checks Java source code for adherence to a set of rules. -// Copyright (C) 2001-2024 the original author or authors. -// -// This library 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. -// -// This library 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 library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//////////////////////////////////////////////////////////////////////////////// -/** - * Sonar rule wrapper classes. - */ -@ParametersAreNonnullByDefault - -package org.sonar.plugins.checkstyle.rule; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java index 7feab365..136aee79 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleConfigurationTest.java @@ -140,7 +140,7 @@ public void getCheckstyleConfiguration() throws Exception { new DefaultActiveRules(Collections.emptyList()), fileSystem); final Configuration checkstyleConfiguration = configuration.getCheckstyleConfiguration(); assertThat(checkstyleConfiguration).isNotNull(); - assertThat(checkstyleConfiguration.getAttribute("charset")).isEqualTo("UTF-8"); + assertThat(checkstyleConfiguration.getProperty("charset")).isEqualTo("UTF-8"); final File xmlFile = new File("checkstyle.xml"); assertThat(xmlFile.exists()).isTrue(); diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java index b40f91fd..c7ea00db 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleExecutorTest.java @@ -20,6 +20,7 @@ package org.sonar.plugins.checkstyle; import static org.fest.assertions.Assertions.assertThat; +import static org.junit.Assert.assertThrows; import static org.mockito.Matchers.any; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; @@ -38,9 +39,7 @@ import org.apache.commons.io.FileUtils; import org.junit.Assert; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.mockito.Mockito; @@ -53,8 +52,7 @@ public class CheckstyleExecutorTest { - @Rule - public final ExpectedException thrown = ExpectedException.none(); + // Remove the 'thrown' field private final SensorContext context = mock(SensorContext.class); @@ -87,20 +85,20 @@ public void execute() throws CheckstyleException { @Test public void executeException() throws CheckstyleException { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("Can not execute Checkstyle"); final CheckstyleConfiguration conf = mockConf(); final CheckstyleExecutor executor = new CheckstyleExecutor(conf, null); - executor.execute(context); + assertThrows("Can not execute Checkstyle", + IllegalStateException.class, + () -> executor.execute(context)); } @Test public void getUrlException() throws URISyntaxException { - thrown.expect(IllegalStateException.class); - thrown.expectMessage("Fail to create the project classloader. " - + "Classpath element is invalid: htp://aa"); final CheckstyleExecutor executor = new CheckstyleExecutor(null, mockListener()); - executor.getUrl(new URI("htp://aa")); + assertThrows("Fail to create the project classloader. " + + "Classpath element is invalid: htp://aa", + IllegalStateException.class, + () -> executor.getUrl(new URI("htp://aa"))); } /** @@ -126,7 +124,8 @@ public void generateXmlReportInEnglish() throws Exception { Assert.assertTrue("Report should exists", report.exists()); - final String reportContents = FileUtils.readFileToString(report); + final String reportContents = FileUtils.readFileToString(report, + Charset.defaultCharset()); assertThat(reportContents).contains(" CheckstyleExecutor.close(closeable)); } private static CheckstyleAuditListener mockListener() { diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstylePluginTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstylePluginTest.java index e58dcc2d..d6e9eba6 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstylePluginTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/CheckstylePluginTest.java @@ -32,7 +32,7 @@ public class CheckstylePluginTest { @Test public void testGetExtensions() { - assertThat(CheckstylePlugin.getExtensions().size()).isEqualTo(11); + assertThat(CheckstylePlugin.getExtensions().size()).isEqualTo(9); } @Test diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest.java index 10f8b3cc..2aff7070 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest.java @@ -44,10 +44,7 @@ import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.config.internal.ConfigurationBridge; import org.sonar.api.config.internal.MapSettings; -import org.sonar.api.profiles.RulesProfile; import org.sonar.api.rule.RuleKey; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; import org.sonar.api.utils.System2; public class CheckstyleProfileExporterTest { @@ -66,71 +63,6 @@ public void tearDown() { System.setProperty("javax.xml.transform.TransformerFactory", ""); } - @Test - public void alwaysSetSuppressionCommentFilter() { - final RulesProfile profile = RulesProfile.create("sonar way", "java"); - - final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); - - CheckstyleTestUtils.assertSimilarXmlWithResource( - "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" - + "alwaysSetSuppressionCommentFilter.xml", - sanitizeForTests(writer.toString())); - } - - @Test - public void noCheckstyleRulesToExport() { - final RulesProfile profile = RulesProfile.create("sonar way", "java"); - - // this is a PMD rule - profile.activateRule(Rule.create("pmd", "PmdRule1", "PMD rule one"), null); - - final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); - - CheckstyleTestUtils.assertSimilarXmlWithResource( - "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" - + "noCheckstyleRulesToExport.xml", sanitizeForTests(writer.toString())); - } - - @Test - public void singleCheckstyleRulesToExport() { - final RulesProfile profile = RulesProfile.create("sonar way", "java"); - profile.activateRule(Rule.create("pmd", "PmdRule1", "PMD rule one"), null); - profile.activateRule( - Rule.create("checkstyle", - "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck", - "Javadoc").setConfigKey("Checker/JavadocPackage"), RulePriority.MAJOR); - profile.activateRule( - Rule.create( - "checkstyle", - "com.puppycrawl.tools.checkstyle.checks.naming.LocalFinalVariableNameCheck", - "Local Variable").setConfigKey( - "Checker/TreeWalker/Checker/TreeWalker/LocalFinalVariableName"), - RulePriority.MINOR); - - final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); - - CheckstyleTestUtils.assertSimilarXmlWithResource( - "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" - + "singleCheckstyleRulesToExport.xml", sanitizeForTests(writer.toString())); - } - - @Test - public void ruleThrowsException() { - final RulesProfile profile = RulesProfile.create("sonar way", "java"); - try { - new CheckstyleProfileExporter(settings).exportProfile(profile, new IoExceptionWriter()); - Assert.fail("IOException while writing should not be ignored"); - } - catch (IllegalStateException ex) { - Assertions.assertThat(ex.getMessage()) - .isEqualTo("Fail to export the profile " + profile); - } - } - @Test public void singleCheckstyleActiveRulesToExport() { final ActiveRules activeRules = Mockito.mock(ActiveRules.class); @@ -158,51 +90,6 @@ public void activeRulesThrowsException() { } } - @Test - public void addTheIdPropertyWhenManyInstancesWithTheSameConfigKey() { - final RulesProfile profile = RulesProfile.create("sonar way", "java"); - final Rule rule1 = Rule.create("checkstyle", - "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck", "Javadoc") - .setConfigKey("Checker/JavadocPackage"); - final Rule rule2 = Rule - .create("checkstyle", - "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck_12345", - "Javadoc").setConfigKey("Checker/JavadocPackage").setParent(rule1); - - profile.activateRule(rule1, RulePriority.MAJOR); - profile.activateRule(rule2, RulePriority.CRITICAL); - - final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); - - CheckstyleTestUtils.assertSimilarXmlWithResource( - "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" - + "addTheIdPropertyWhenManyInstancesWithTheSameConfigKey.xml", - sanitizeForTests(writer.toString())); - } - - @Test - public void exportParameters() { - final RulesProfile profile = RulesProfile.create("sonar way", "java"); - final Rule rule = Rule.create("checkstyle", - "com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck", "Javadoc") - .setConfigKey("Checker/JavadocPackage"); - rule.createParameter("format"); - // not set in the profile and no default value => not exported in - // checkstyle - rule.createParameter("message"); - rule.createParameter("ignore"); - - profile.activateRule(rule, RulePriority.MAJOR).setParameter("format", "abcde"); - - final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); - - CheckstyleTestUtils.assertSimilarXmlWithResource( - "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" - + "exportParameters.xml", sanitizeForTests(writer.toString())); - } - @Test public void addCustomCheckerFilters() { initSettings(CheckstyleConstants.CHECKER_FILTERS_KEY, @@ -215,9 +102,11 @@ public void addCustomCheckerFilters() { + "" + "" + "
"); - final RulesProfile profile = RulesProfile.create("sonar way", "java"); + final ActiveRules activeRules = Mockito.mock(ActiveRules.class); + Mockito.when(activeRules.findByRepository(CheckstyleConstants.REPOSITORY_KEY)) + .thenReturn(Collections.singletonList(new TestActiveRule())); final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); + new CheckstyleProfileExporter(settings).exportProfile(activeRules, writer); CheckstyleTestUtils.assertSimilarXmlWithResource( "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" @@ -229,9 +118,11 @@ public void addCustomTreewalkerFilters() { initSettings(CheckstyleConstants.TREEWALKER_FILTERS_KEY, ""); - final RulesProfile profile = RulesProfile.create("sonar way", "java"); + final ActiveRules activeRules = Mockito.mock(ActiveRules.class); + Mockito.when(activeRules.findByRepository(CheckstyleConstants.REPOSITORY_KEY)) + .thenReturn(Collections.singletonList(new TestActiveRule())); final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); + new CheckstyleProfileExporter(settings).exportProfile(activeRules, writer); CheckstyleTestUtils.assertSimilarXmlWithResource( "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" @@ -242,9 +133,11 @@ public void addCustomTreewalkerFilters() { public void addTabWidthProperty() { initSettings(CheckstyleConstants.CHECKER_TAB_WIDTH, "8"); - final RulesProfile profile = RulesProfile.create("sonar way", "java"); + final ActiveRules activeRules = Mockito.mock(ActiveRules.class); + Mockito.when(activeRules.findByRepository(CheckstyleConstants.REPOSITORY_KEY)) + .thenReturn(Collections.singletonList(new TestActiveRule())); final StringWriter writer = new StringWriter(); - new CheckstyleProfileExporter(settings).exportProfile(profile, writer); + new CheckstyleProfileExporter(settings).exportProfile(activeRules, writer); CheckstyleTestUtils.assertSimilarXmlWithResource( "/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/" @@ -327,7 +220,9 @@ public String qpKey() { @Override public Map params() { - return new HashMap<>(); + final Map params = new HashMap<>(); + params.put("format", "abcde"); + return params; } @CheckForNull diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java deleted file mode 100644 index 8e0baafe..00000000 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest.java +++ /dev/null @@ -1,237 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// checkstyle: Checks Java source code for adherence to a set of rules. -// Copyright (C) 2001-2024 the original author or authors. -// -// This library 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. -// -// This library 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 library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -//////////////////////////////////////////////////////////////////////////////// - -package org.sonar.plugins.checkstyle; - -import static org.fest.assertions.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.Reader; -import java.io.StringReader; - -import org.apache.commons.lang.StringUtils; -import org.junit.Before; -import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RuleFinder; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.rules.RuleQuery; -import org.sonar.api.utils.ValidationMessages; - -public class CheckstyleProfileImporterTest { - - private ValidationMessages messages; - private CheckstyleProfileImporter importer; - - @Before - public void before() { - messages = ValidationMessages.create(); - - /* - * The mocked rule finder defines 3 rules : - * - * - JavadocCheck with 2 paramters format and ignore, default priority - * is MAJOR - * - EqualsHashCodeCheck without parameters, default priority - * is BLOCKER - * - MissingOverride with 1 parameter javaFiveCompatibility, - * default priority is MINOR - */ - importer = new CheckstyleProfileImporter(newRuleFinder()); - } - - @Test - public void importSimpleProfile() { - final Reader reader = new StringReader(CheckstyleTestUtils.getResourceContent( - "/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/simple.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - assertThat(profile.getActiveRules().size()).isEqualTo(2); - assertNotNull(profile.getActiveRuleByConfigKey("checkstyle", - "Checker/TreeWalker/EqualsHashCode")); - assertNotNull(profile.getActiveRuleByConfigKey("checkstyle", "Checker/JavadocPackage")); - assertThat(messages.hasErrors()).isFalse(); - } - - @Test - public void importParameters() { - final Reader reader = new StringReader(CheckstyleTestUtils.getResourceContent( - "/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/simple.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - final ActiveRule javadocCheck = profile.getActiveRuleByConfigKey("checkstyle", - "Checker/JavadocPackage"); - assertThat(javadocCheck.getActiveRuleParams()).hasSize(2); - assertThat(javadocCheck.getParameter("format")).isEqualTo("abcde"); - assertThat(javadocCheck.getParameter("ignore")).isEqualTo("true"); - // checkstyle internal parameter - assertThat(javadocCheck.getParameter("severity")).isNull(); - } - - @Test - public void propertiesShouldBeInherited() { - final Reader reader = new StringReader(CheckstyleTestUtils.getResourceContent( - "/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/" - + "inheritance_of_properties.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - final ActiveRule activeRule = profile.getActiveRuleByConfigKey("checkstyle", - "Checker/TreeWalker/MissingOverride"); - assertThat(activeRule.getSeverity()).isEqualTo(RulePriority.BLOCKER); - assertThat(activeRule.getParameter("javaFiveCompatibility")).isEqualTo("true"); - } - - @Test - public void importPriorities() { - final Reader reader = new StringReader(CheckstyleTestUtils.getResourceContent( - "/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/simple.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - final ActiveRule javadocCheck = profile.getActiveRuleByConfigKey("checkstyle", - "Checker/JavadocPackage"); - assertThat(javadocCheck.getSeverity()).isEqualTo(RulePriority.BLOCKER); - } - - @Test - public void priorityIsOptional() { - final Reader reader = new StringReader(CheckstyleTestUtils.getResourceContent( - "/org/sonar/plugins/checkstyle/" - + "CheckstyleProfileImporterTest/simple.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - final ActiveRule activeRule = profile.getActiveRuleByConfigKey("checkstyle", - "Checker/TreeWalker/EqualsHashCode"); - // reuse the rule default priority - assertThat(activeRule.getSeverity()).isEqualTo(RulePriority.BLOCKER); - } - - @Test - public void idPropertyShouldBeTheRuleKey() { - final Reader reader = new StringReader(CheckstyleTestUtils.getResourceContent( - "/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/" - + "idPropertyShouldBeTheRuleKey.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - assertNull(profile.getActiveRuleByConfigKey("checkstyle", "Checker/JavadocPackage")); - assertThat(messages.getWarnings().size()).isEqualTo(1); - } - - @Test - public void shouldUseTheIdPropertyToFindRule() { - final Reader reader = new StringReader( - CheckstyleTestUtils.getResourceContent("/org/sonar/plugins/checkstyle/" - + "CheckstyleProfileImporterTest/shouldUseTheIdPropertyToFindRule.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - assertNotNull(profile.getActiveRuleByConfigKey("checkstyle", "Checker/JavadocPackage")); - assertThat( - profile.getActiveRuleByConfigKey("checkstyle", "Checker/JavadocPackage").getRule() - .getKey()).isEqualTo( - "com.puppycrawl.tools.checkstyle.checks.javadoc." + "JavadocPackageCheck_12345"); - assertThat(messages.getWarnings().size()).isEqualTo(0); - } - - @Test - public void testUnvalidXml() { - final Reader reader = new StringReader("not xml"); - importer.importProfile(reader, messages); - assertThat(messages.getErrors().size()).isEqualTo(1); - } - - @Test - public void importingFiltersIsNotSupported() { - final Reader reader = new StringReader( - CheckstyleTestUtils.getResourceContent("/org/sonar/plugins/checkstyle/" - + "CheckstyleProfileImporterTest/importingFiltersIsNotSupported.xml")); - final RulesProfile profile = importer.importProfile(reader, messages); - - assertNull(profile.getActiveRuleByConfigKey("checkstyle", - "Checker/SuppressionCommentFilter")); - assertThat(profile.getActiveRules().size()).isEqualTo(2); - assertThat(messages.getWarnings().size()).isEqualTo(5); - } - - private static RuleFinder newRuleFinder() { - final RuleFinder ruleFinder = mock(RuleFinder.class); - when(ruleFinder.find(any(RuleQuery.class))).thenAnswer(new RuleAnswer()); - return ruleFinder; - } - - private static final class RuleAnswer implements Answer { - @Override - public Rule answer(InvocationOnMock iom) { - final RuleQuery query = (RuleQuery) iom.getArguments()[0]; - Rule rule = null; - if (StringUtils.equals(query.getConfigKey(), "Checker/JavadocPackage")) { - rule = Rule - .create(query.getRepositoryKey(), - "com.puppycrawl.tools.checkstyle.checks.javadoc." - + "JavadocPackageCheck", "Javadoc Package") - .setConfigKey("Checker/JavadocPackage") - .setSeverity(RulePriority.MAJOR); - rule.createParameter("format"); - rule.createParameter("ignore"); - - } - else if (StringUtils.equals(query.getConfigKey(), - "Checker/TreeWalker/EqualsHashCode")) { - rule = Rule - .create(query.getRepositoryKey(), - "com.puppycrawl.tools.checkstyle.checks.coding." - + "EqualsHashCodeCheck", - "Equals HashCode") - .setConfigKey("Checker/TreeWalker/EqualsHashCode") - .setSeverity(RulePriority.BLOCKER); - - } - else if (StringUtils.equals(query.getKey(), - "com.puppycrawl.tools.checkstyle.checks.javadoc." - + "JavadocPackageCheck_12345")) { - rule = Rule - .create(query.getRepositoryKey(), - "com.puppycrawl.tools.checkstyle.checks.javadoc." - + "JavadocPackageCheck_12345", - "Javadoc Package").setConfigKey("Checker/JavadocPackage") - .setSeverity(RulePriority.MAJOR); - rule.createParameter("format"); - rule.createParameter("ignore"); - } - else if (StringUtils.equals(query.getConfigKey(), - "Checker/TreeWalker/MissingOverride")) { - rule = Rule - .create(query.getRepositoryKey(), - "com.puppycrawl.tools.checkstyle.checks.annotation." - + "MissingOverrideCheck", - "Missing Override") - .setConfigKey("Checker/TreeWalker/MissingOverride") - .setSeverity(RulePriority.MINOR); - rule.createParameter("javaFiveCompatibility"); - } - return rule; - } - } -} diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java index dc9df3c0..87824ab8 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRulesDefinitionTest.java @@ -27,9 +27,7 @@ import java.util.Map.Entry; import java.util.stream.Collectors; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.sonar.api.server.rule.RulesDefinition; import com.google.common.collect.ImmutableList; @@ -50,9 +48,6 @@ public class CheckstyleRulesDefinitionTest { "com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolder" ); - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Test public void test() { final CheckstyleRulesDefinition definition = new CheckstyleRulesDefinition(); diff --git a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtilsTest.java b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtilsTest.java index 731a071f..46212829 100644 --- a/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtilsTest.java +++ b/src/test/java/org/sonar/plugins/checkstyle/CheckstyleSeverityUtilsTest.java @@ -26,19 +26,9 @@ import org.junit.Assert; import org.junit.Test; -import org.sonar.api.rules.RulePriority; public class CheckstyleSeverityUtilsTest { - @Test - public void testToSeverity() { - assertThat(CheckstyleSeverityUtils.toSeverity(RulePriority.BLOCKER)).isEqualTo("error"); - assertThat(CheckstyleSeverityUtils.toSeverity(RulePriority.CRITICAL)).isEqualTo("error"); - assertThat(CheckstyleSeverityUtils.toSeverity(RulePriority.MAJOR)).isEqualTo("warning"); - assertThat(CheckstyleSeverityUtils.toSeverity(RulePriority.MINOR)).isEqualTo("info"); - assertThat(CheckstyleSeverityUtils.toSeverity(RulePriority.INFO)).isEqualTo("info"); - } - @Test public void testToSeverityString() { assertThat(CheckstyleSeverityUtils.toSeverity("BLOCKER")).isEqualTo("error"); @@ -59,15 +49,6 @@ public void testToSeverityWrongString() { } } - @Test - public void testFromSeverity() { - assertThat(CheckstyleSeverityUtils.fromSeverity("error")).isEqualTo(RulePriority.BLOCKER); - assertThat(CheckstyleSeverityUtils.fromSeverity("warning")).isEqualTo(RulePriority.MAJOR); - assertThat(CheckstyleSeverityUtils.fromSeverity("info")).isEqualTo(RulePriority.INFO); - assertThat(CheckstyleSeverityUtils.fromSeverity("ignore")).isEqualTo(RulePriority.INFO); - assertThat(CheckstyleSeverityUtils.fromSeverity("")).isNull(); - } - @Test public void privateConstructor() throws ReflectiveOperationException { final Constructor constructor = CheckstyleSeverityUtils.class diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomFilters.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomFilters.xml index f3c2062d..9a04133b 100644 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomFilters.xml +++ b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomFilters.xml @@ -1,5 +1,4 @@ - - + @@ -10,8 +9,12 @@ - + + + + + - + diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomTreewalkerFilters.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomTreewalkerFilters.xml index b6121180..aea7e361 100644 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomTreewalkerFilters.xml +++ b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addCustomTreewalkerFilters.xml @@ -1,7 +1,11 @@ - - + + + + + + diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTabWidthProperty.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTabWidthProperty.xml index 0d498b9e..7ca5f2b1 100644 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTabWidthProperty.xml +++ b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTabWidthProperty.xml @@ -1,10 +1,14 @@ - - + - - - - - - + + + + + + + + + + + diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTheIdPropertyWhenManyInstancesWithTheSameConfigKey.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTheIdPropertyWhenManyInstancesWithTheSameConfigKey.xml deleted file mode 100644 index 64cfe607..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/addTheIdPropertyWhenManyInstancesWithTheSameConfigKey.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/alwaysSetSuppressionCommentFilter.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/alwaysSetSuppressionCommentFilter.xml deleted file mode 100644 index 67631fd4..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/alwaysSetSuppressionCommentFilter.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/exportParameters.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/exportParameters.xml deleted file mode 100644 index 0062f94c..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/exportParameters.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/noCheckstyleRulesToExport.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/noCheckstyleRulesToExport.xml deleted file mode 100644 index 67631fd4..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/noCheckstyleRulesToExport.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleActiveRulesToExport.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleActiveRulesToExport.xml index f96040ab..6d95aafa 100644 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleActiveRulesToExport.xml +++ b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleActiveRulesToExport.xml @@ -1,12 +1,13 @@ - + + - + diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleRulesToExport.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleRulesToExport.xml deleted file mode 100644 index 635a0a2a..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileExporterTest/singleCheckstyleRulesToExport.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/idPropertyShouldBeTheRuleKey.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/idPropertyShouldBeTheRuleKey.xml deleted file mode 100644 index 6ef4919b..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/idPropertyShouldBeTheRuleKey.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/importingFiltersIsNotSupported.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/importingFiltersIsNotSupported.xml deleted file mode 100644 index 621514a3..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/importingFiltersIsNotSupported.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/inheritance_of_properties.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/inheritance_of_properties.xml deleted file mode 100644 index 8b038b7b..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/inheritance_of_properties.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/shouldUseTheIdPropertyToFindRule.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/shouldUseTheIdPropertyToFindRule.xml deleted file mode 100644 index 05fd89bb..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/shouldUseTheIdPropertyToFindRule.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/simple.xml b/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/simple.xml deleted file mode 100644 index 9bded9d7..00000000 --- a/src/test/resources/org/sonar/plugins/checkstyle/CheckstyleProfileImporterTest/simple.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - -