diff options
author | Godin <mandrikov@gmail.com> | 2010-11-16 16:08:53 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-11-16 16:08:53 +0000 |
commit | 85d749e23f32af63e4349931575e60abc4be857a (patch) | |
tree | 1d1d2744d746df2c793c07eec259a011b17ddb0c /sonar-plugin-api | |
parent | 24d1f256af0f8655003c84766d53bb04399d5939 (diff) | |
download | sonarqube-85d749e23f32af63e4349931575e60abc4be857a.tar.gz sonarqube-85d749e23f32af63e4349931575e60abc4be857a.zip |
Increase code coverage for XMLRuleParser
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java index c444fdda875..02027741ceb 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/rules/XMLRuleParserTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.sonar.api.utils.SonarException; import org.sonar.check.Cardinality; +import java.io.File; import java.io.StringReader; import java.util.List; @@ -35,8 +36,9 @@ import static org.junit.Assert.assertThat; public class XMLRuleParserTest { @Test - public void parseXml() { - List<Rule> rules = new XMLRuleParser().parse(getClass().getResourceAsStream("/org/sonar/api/rules/XMLRuleParserTest/rules.xml")); + public void parseXml() throws Exception { + File file = new File(getClass().getResource("/org/sonar/api/rules/XMLRuleParserTest/rules.xml").toURI()); + List<Rule> rules = new XMLRuleParser().parse(file); assertThat(rules.size(), is(2)); Rule rule = rules.get(0); @@ -64,6 +66,11 @@ public class XMLRuleParserTest { } @Test(expected = SonarException.class) + public void failIfMissingRuleName() { + new XMLRuleParser().parse(new StringReader("<rules><rule><key>foo</key></rule></rules>")); + } + + @Test(expected = SonarException.class) public void failIfMissingPropertyKey() { new XMLRuleParser().parse(new StringReader("<rules><rule><key>foo</key><name>Foo</name><param></param></rule></rules>")); } |