Class RuleTst

    • Constructor Detail

      • RuleTst

        public RuleTst()
    • Method Detail

      • setUp

        protected void setUp()
      • getRules

        protected List<net.sourceforge.pmd.Rule> getRules()
      • findRule

        public net.sourceforge.pmd.Rule findRule​(String ruleSet,
                                                 String ruleName)
        Find a rule in a certain ruleset by name
      • runTest

        public void runTest​(TestDescriptor test)
        Run the rule on the given code, and check the expected number of violations.
      • reinitializeRule

        protected net.sourceforge.pmd.Rule reinitializeRule​(net.sourceforge.pmd.Rule rule)
        Code to be executed if the rule is reinitialised.
        Parameters:
        rule - The rule to reinitialise
        Returns:
        The rule once it has been reinitialised
      • runTestFromString

        public void runTestFromString​(String code,
                                      net.sourceforge.pmd.Rule rule,
                                      net.sourceforge.pmd.Report report,
                                      net.sourceforge.pmd.lang.LanguageVersion languageVersion)
        Run the rule on the given code and put the violations in the report.
      • runTestFromString

        public void runTestFromString​(String code,
                                      net.sourceforge.pmd.Rule rule,
                                      net.sourceforge.pmd.Report report,
                                      net.sourceforge.pmd.lang.LanguageVersion languageVersion,
                                      boolean isUseAuxClasspath)
      • runTestFromString

        public void runTestFromString​(TestDescriptor test,
                                      net.sourceforge.pmd.Rule rule,
                                      net.sourceforge.pmd.Report report)
      • getCleanRuleName

        protected String getCleanRuleName​(net.sourceforge.pmd.Rule rule)
        getResourceAsStream tries to find the XML file in weird locations if the ruleName includes the package, so we strip it here.
      • extractTestsFromXml

        public TestDescriptor[] extractTestsFromXml​(net.sourceforge.pmd.Rule rule)
        Extract a set of tests from an XML file. The file should be ./xml/RuleName.xml relative to the test class. The format is defined in test-data.xsd.
      • extractTestsFromXml

        public TestDescriptor[] extractTestsFromXml​(net.sourceforge.pmd.Rule rule,
                                                    String testsFileName)
      • extractTestsFromXml

        public TestDescriptor[] extractTestsFromXml​(net.sourceforge.pmd.Rule rule,
                                                    String testsFileName,
                                                    String baseDirectory)
        Extract a set of tests from an XML file with the given name. The file should be ./xml/[testsFileName].xml relative to the test class. The format is defined in test-data.xsd.
      • runTests

        public void runTests​(net.sourceforge.pmd.Rule rule)
        Run a set of tests defined in an XML test-data file for a rule. The file should be ./xml/RuleName.xml relative to the test-class. The format is defined in test-data.xsd.
      • runTests

        public void runTests​(net.sourceforge.pmd.Rule rule,
                             String testsFileName)
        Run a set of tests defined in a XML test-data file. The file should be ./xml/[testsFileName].xml relative to the test-class. The format is defined in test-data.xsd.
      • runTests

        public void runTests​(TestDescriptor[] tests)
        Run a set of tests of a certain sourceType.