@Test public void exportEmptyProfile() throws IOException, SAXException { Writer writer = new StringWriter(); RulesProfile profile = RulesProfile.create("sonar way", "java"); new XMLProfileSerializer().write(profile, writer); assertSimilarXml("exportEmptyProfile.xml", writer.toString()); }
@Test public void exportProfile() throws IOException, SAXException { Writer writer = new StringWriter(); RulesProfile profile = RulesProfile.create("sonar way", "java"); profile.activateRule(Rule.create("checkstyle", "IllegalRegexp", "illegal regexp"), RulePriority.BLOCKER); new XMLProfileSerializer().write(profile, writer); assertSimilarXml("exportProfile.xml", writer.toString()); }
@Test public void exportRuleParameters() throws IOException, SAXException { Writer writer = new StringWriter(); RulesProfile profile = RulesProfile.create("sonar way", "java"); Rule rule = Rule.create("checkstyle", "IllegalRegexp", "illegal regexp"); rule.createParameter("format"); rule.createParameter("message"); rule.createParameter("tokens"); ActiveRule activeRule = profile.activateRule(rule, RulePriority.BLOCKER); activeRule.setParameter("format", "foo"); activeRule.setParameter("message", "with special characters < > &"); // the tokens parameter is not set new XMLProfileSerializer().write(profile, writer); assertSimilarXml("exportRuleParameters.xml", writer.toString()); }