1 package test.net.sourceforge.pmd.rules;
2
3 import net.sourceforge.pmd.PMD;
4 import net.sourceforge.pmd.Rule;
5 import net.sourceforge.pmd.rules.XPathRule;
6
7 public class EmptyIfStmtRuleTest extends SimpleAggregatorTst {
8
9 private Rule rule;
10
11 public void setUp() {
12 rule = new XPathRule();
13 rule.addProperty("xpath", "//IfStatement/Statement/Block[count(*) = 0]");
14 }
15
16 public void testAll() {
17 runTests(new TestDescriptor[] {
18 new TestDescriptor(TEST1, "one empty, one not empty", 1, rule),
19 });
20 }
21
22 private static final String TEST1 =
23 "public class EmptyIfStmtRule {" + PMD.EOL +
24 " public EmptyIfStmtRule() {" + PMD.EOL +
25 " if (null == null) {" + PMD.EOL +
26 " }" + PMD.EOL +
27 " if (null != null) {" + PMD.EOL +
28 " this.toString();" + PMD.EOL +
29 " }" + PMD.EOL +
30 " }" + PMD.EOL +
31 "}";
32
33
34 }
This page was automatically generated by Maven