RuleSetFactory { public RuleSets createRuleSets(String referenceString) throws RuleSetNotFoundException { return createRuleSets(RuleSetReferenceId.parse(referenceString)); } @Deprecated // to be removed with PMD 7.0.0.  RuleSetFactory(); @Deprecated // to be removed with PMD 7.0.0.  RuleSetFactory(final ClassLoader classLoader, final RulePriority minimumPriority,
                          final boolean warnDeprecated, final boolean enableCompatibility); @Deprecated // to be hidden with PMD 7.0.0.  RuleSetFactory(final ResourceLoader resourceLoader, final RulePriority minimumPriority,
                          final boolean warnDeprecated, final boolean enableCompatibility);  RuleSetFactory(final RuleSetFactory factory, final boolean warnDeprecated); Iterator<RuleSet> getRegisteredRuleSets(); RuleSets createRuleSets(String referenceString); RuleSets createRuleSets(List<RuleSetReferenceId> ruleSetReferenceIds); RuleSet createRuleSet(String referenceString); RuleSet createRuleSet(RuleSetReferenceId ruleSetReferenceId); RuleSet createRuleSetCopy(RuleSet original); RuleSet createNewRuleSet(String name,
                                    String description,
                                    String fileName,
                                    Collection<String> excludePatterns,
                                    Collection<String> includePatterns,
                                    Collection<Rule> rules); RuleSet createSingleRuleRuleSet(final Rule rule);  }
@Test public void testExtendedReferences() throws Exception { InputStream in = new ResourceLoader().loadClassPathResourceAsStream("net/sourceforge/pmd/rulesets/reference-ruleset.xml"); assertNotNull("Test ruleset not found - can't continue with test!", in); in.close(); RuleSetFactory rsf = RulesetsFactoryUtils.defaultFactory(); RuleSets rs = rsf.createRuleSets("net/sourceforge/pmd/rulesets/reference-ruleset.xml"); assertNotNull(rs.getRuleByName("MockRule1")); assertNotNull(rs.getRuleByName("MockRule2")); assertNotNull(rs.getRuleByName("MockRule3")); assertNotNull(rs.getRuleByName("TestRuleRef")); assertNotNull(rs.getRuleByName("TestRule")); assertNull(rs.getRuleByName("TestRule2Ruleset2")); Rule mockRule3 = rs.getRuleByName("MockRule3"); assertEquals("Overridden message", mockRule3.getMessage()); assertEquals(2, mockRule3.getPriority().getPriority()); Rule mockRule2 = rs.getRuleByName("MockRule2"); assertEquals("Just combine them!", mockRule2.getMessage()); assertEquals(1, countRule(rs, "MockRule2")); Rule mockRule1 = rs.getRuleByName("MockRule1"); assertNotNull(mockRule1); PropertyDescriptor<?> prop = mockRule1.getPropertyDescriptor("testIntProperty"); Object property = mockRule1.getProperty(prop); assertEquals("5", String.valueOf(property)); assertNotNull(rs.getRuleByName("Ruleset3Rule2")); assertNull(rs.getRuleByName("Ruleset3Rule1")); Rule ruleset4Rule1 = rs.getRuleByName("Ruleset4Rule1"); assertNotNull(ruleset4Rule1); assertEquals(5, ruleset4Rule1.getPriority().getPriority()); assertEquals(1, countRule(rs, "Ruleset4Rule1")); Rule ruleset4Rule2 = rs.getRuleByName("Ruleset4Rule2"); assertNotNull(ruleset4Rule2); assertEquals(2, ruleset4Rule2.getPriority().getPriority()); }