View Javadoc
1 /*** 2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html 3 */ 4 package test.net.sourceforge.pmd.rules; 5 6 import net.sourceforge.pmd.PMD; 7 import net.sourceforge.pmd.Rule; 8 import net.sourceforge.pmd.rules.XPathRule; 9 import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst; 10 import test.net.sourceforge.pmd.testframework.TestDescriptor; 11 12 public class EmptyIfStmtRuleTest extends SimpleAggregatorTst { 13 14 private Rule rule; 15 16 public void setUp() { 17 rule = new XPathRule(); 18 rule.addProperty("xpath", "//IfStatement/Statement/Block[count(*) = 0]"); 19 } 20 21 public void testAll() { 22 runTests(new TestDescriptor[] { 23 new TestDescriptor(TEST1, "one empty, one not empty", 1, rule), 24 }); 25 } 26 27 private static final String TEST1 = 28 "public class EmptyIfStmtRule {" + PMD.EOL + 29 " public EmptyIfStmtRule() {" + PMD.EOL + 30 " if (null == null) {" + PMD.EOL + 31 " }" + PMD.EOL + 32 " if (null != null) {" + PMD.EOL + 33 " this.toString();" + PMD.EOL + 34 " }" + PMD.EOL + 35 " }" + PMD.EOL + 36 "}"; 37 38 39 }

This page was automatically generated by Maven