View Javadoc
1 package test.net.sourceforge.pmd.rules; 2 3 import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst; 4 import test.net.sourceforge.pmd.testframework.TestDescriptor; 5 import net.sourceforge.pmd.Rule; 6 import net.sourceforge.pmd.PMD; 7 import net.sourceforge.pmd.rules.XPathRule; 8 9 public class EmptyFinalizerRuleTest extends SimpleAggregatorTst { 10 private Rule rule; 11 12 public void setUp() { 13 rule = new XPathRule(); 14 rule.addProperty( 15 "xpath", 16 "//MethodDeclaration[MethodDeclarator[@Image='finalize'][not(FormalParameters/*)]]/Block[count(*)=0]"); 17 } 18 19 public void testAll() { 20 runTests(new TestDescriptor[] { 21 new TestDescriptor(TEST1, "simple failure", 1, rule), 22 new TestDescriptor(TEST2, "ok", 0, rule), 23 }); 24 } 25 26 private static final String TEST1 = 27 "public class Foo {" + PMD.EOL + 28 " void finalize() {}" + PMD.EOL + 29 "}"; 30 31 private static final String TEST2 = 32 "public class Foo {" + PMD.EOL + 33 " void finalize() { int x = 2;}" + PMD.EOL + 34 "}"; 35 36 }

This page was automatically generated by Maven