Merge branch 'pr-2476'

[java] MethodNamingConventions - Add support for JUnit 5 method naming #2476
This commit is contained in:
Andreas Dangel
2020-05-22 19:30:41 +02:00
7 changed files with 136 additions and 8 deletions

View File

@@ -274,6 +274,20 @@ public abstract class RuleTst {
if (isUseAuxClasspath) {
// configure the "auxclasspath" option for unit testing
p.getConfiguration().prependClasspath(".");
} 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.
p.getConfiguration().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);
}
});
}
RuleContext ctx = new RuleContext();
ctx.setReport(report);