Fix compile errors
This commit is contained in:
@ -17,8 +17,8 @@ import net.sourceforge.pmd.lang.DummyLanguageModule;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.ast.DummyNode;
|
||||
import net.sourceforge.pmd.lang.ast.DummyNodeWithDeprecatedAttribute;
|
||||
import net.sourceforge.pmd.lang.ast.DummyRoot;
|
||||
import net.sourceforge.pmd.lang.ast.DummyNodeWithListAndEnum;
|
||||
import net.sourceforge.pmd.lang.ast.DummyRoot;
|
||||
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.XPathVersion;
|
||||
|
||||
@ -45,26 +45,26 @@ public class XPathRuleTest {
|
||||
RuleContext ctx = new RuleContext();
|
||||
ctx.setLanguageVersion(LanguageRegistry.getLanguage(DummyLanguageModule.NAME).getDefaultVersion());
|
||||
DummyNode firstNode = newNodeWithList();
|
||||
eval(ctx, xpr, firstNode);
|
||||
xpr.apply(firstNode, ctx);
|
||||
assertEquals(1, ctx.getReport().size());
|
||||
|
||||
String log = loggingRule.getLog();
|
||||
assertThat(log, Matchers.containsString("Use of deprecated attribute 'dummyNode/@List' by XPath rule 'TestRuleWithListAccess'"));
|
||||
|
||||
loggingRule.clear();
|
||||
eval(ctx, xpr, newNodeWithList()); // with another node
|
||||
xpr.apply(newNodeWithList(), ctx); // with another node
|
||||
assertEquals(2, ctx.getReport().size());
|
||||
assertEquals("", loggingRule.getLog()); // no addtional warnings
|
||||
|
||||
// with another rule forked from the same one (in multithreaded processor)
|
||||
eval(ctx, xpr.deepCopy(), newNodeWithList());
|
||||
xpr.deepCopy().apply(newNodeWithList(), ctx);
|
||||
assertEquals(3, ctx.getReport().size());
|
||||
assertEquals("", loggingRule.getLog()); // no addtional warnings
|
||||
|
||||
// with another rule on the same node, new warnings
|
||||
XPathRule otherRule = makeRuleWithList("OtherTestRuleWithListAccess");
|
||||
otherRule.setRuleSetName("rset.xml");
|
||||
eval(ctx, otherRule, firstNode);
|
||||
otherRule.apply(firstNode, ctx);
|
||||
assertEquals(4, ctx.getReport().size());
|
||||
log = loggingRule.getLog();
|
||||
assertThat(log, Matchers.containsString("Use of deprecated attribute 'dummyNode/@List' by XPath rule 'OtherTestRuleWithListAccess' (in ruleset 'rset.xml')"));
|
||||
@ -80,9 +80,11 @@ public class XPathRuleTest {
|
||||
|
||||
|
||||
private DummyNode newNodeWithList() {
|
||||
DummyRoot root = new DummyRoot();
|
||||
DummyNode firstNode = new DummyNodeWithListAndEnum(0);
|
||||
firstNode.setCoords(1, 1, 1, 2);
|
||||
return firstNode;
|
||||
root.addChild(firstNode, 0);
|
||||
return root;
|
||||
}
|
||||
|
||||
public void testDeprecation(XPathVersion version) {
|
||||
|
Reference in New Issue
Block a user