[test] Remove unused code from RuleTst

This commit is contained in:
Andreas Dangel
2022-07-22 21:06:21 +02:00
parent cb5acd6389
commit bc7bbed1b4
2 changed files with 9 additions and 21 deletions

View File

@ -81,9 +81,8 @@ public abstract class RuleTst {
public void runTest(TestDescriptor test) {
Rule rule = test.getRule();
if (test.getReinitializeRule()) {
rule = reinitializeRule(rule);
}
// always reinitialize the rule, regardless of test.getReinitializeRule() (#3976 / #3302)
rule = reinitializeRule(rule);
Map<PropertyDescriptor<?>, Object> oldProperties = rule.getPropertiesByPropertyDescriptor();
try {
@ -237,24 +236,9 @@ public abstract class RuleTst {
PMDConfiguration configuration = new PMDConfiguration();
configuration.setDefaultLanguageVersion(languageVersion);
configuration.setIgnoreIncrementalAnalysis(true);
if (isUseAuxClasspath) {
// configure the "auxclasspath" option for unit testing
configuration.prependAuxClasspath(".");
} else {
// simple class loader, that doesn't delegate to parent.
// this allows us in the tests to simulate PMD run without
// auxclasspath, not even the classes from the test dependencies
// will be found.
configuration.setClassLoader(new ClassLoader() {
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
if (name.startsWith("java.") || name.startsWith("javax.")) {
return super.loadClass(name, resolve);
}
throw new ClassNotFoundException(name);
}
});
}
// regardless of isUseAuxClasspath the auxclasspath is always used (#3976 / #3302)
// configure the "auxclasspath" option for unit testing
configuration.prependAuxClasspath(".");
RuleContext ctx = new RuleContext();
ctx.setReport(report);
ctx.setSourceCodeFile(new File("n/a"));

View File

@ -36,6 +36,10 @@ public class RuleTstTest {
private Rule rule = mock(Rule.class);
private RuleTst ruleTester = new RuleTst() {
@Override
public Rule findRule(String ruleSet, String ruleName) {
return rule;
}
};
@Test