Package net.sourceforge.pmd
Class AbstractRuleSetFactoryTest
- java.lang.Object
-
- net.sourceforge.pmd.AbstractRuleSetFactoryTest
-
public abstract class AbstractRuleSetFactoryTest extends Object
Base test class to verify the language's rulesets. This class should be subclassed for each language.
-
-
Field Summary
Fields Modifier and Type Field Description org.junit.contrib.java.lang.system.SystemErrRulesystemErrRuleprotected Set<String>validXPathClassNames
-
Constructor Summary
Constructors Constructor Description AbstractRuleSetFactoryTest()AbstractRuleSetFactoryTest(String... languagesToSkip)Constructor used when a module that depends on another module wants to filter out the dependee's rulesets.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static RuleSetReferenceIdcreateRuleSetReferenceId(String ruleSetXml)Create aRuleSetReferenceIdby the given XML string.static voidinit()Setups the XML parser with validation.voidtestAllPMDBuiltInRulesMeetConventions()Checks all rulesets of all languages on the classpath and verifies that all required attributes for all rules are specified.voidtestDtd()Verifies that all rulesets are valid XML according to the DTD.voidtestReadWriteRoundTrip()Reads and writes the rulesets to make sure, that no data is lost if the rulests are processed.voidtestXmlSchema()Verifies that all rulesets are valid XML according to the xsd schema.
-
-
-
Constructor Detail
-
AbstractRuleSetFactoryTest
public AbstractRuleSetFactoryTest()
-
AbstractRuleSetFactoryTest
public AbstractRuleSetFactoryTest(String... languagesToSkip)
Constructor used when a module that depends on another module wants to filter out the dependee's rulesets.- Parameters:
languagesToSkip-Languages terse names that appear in the classpath via a dependency, but should be skipped because they aren't the primary language which the concrete instance of this class is testing.
-
-
Method Detail
-
init
public static void init() throws ExceptionSetups the XML parser with validation.- Throws:
Exception- any error
-
testAllPMDBuiltInRulesMeetConventions
public void testAllPMDBuiltInRulesMeetConventions() throws ExceptionChecks all rulesets of all languages on the classpath and verifies that all required attributes for all rules are specified.- Throws:
Exception- any error
-
testXmlSchema
public void testXmlSchema() throws ExceptionVerifies that all rulesets are valid XML according to the xsd schema.- Throws:
Exception- any error
-
testDtd
public void testDtd() throws ExceptionVerifies that all rulesets are valid XML according to the DTD.- Throws:
Exception- any error
-
testReadWriteRoundTrip
public void testReadWriteRoundTrip() throws ExceptionReads and writes the rulesets to make sure, that no data is lost if the rulests are processed.- Throws:
Exception- any error
-
createRuleSetReferenceId
protected static RuleSetReferenceId createRuleSetReferenceId(String ruleSetXml)
Create aRuleSetReferenceIdby the given XML string.- Parameters:
ruleSetXml- the ruleset file content as string- Returns:
- the
RuleSetReferenceId
-
-