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