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 BooleanInstantiationRuleTest extends SimpleAggregatorTst {
8
9 private Rule rule;
10
11 public void setUp() {
12 rule = new XPathRule();
13 rule.addProperty(
14 "xpath",
15 "//AllocationExpression[not (ArrayDimsAndInits) and (Name/@Image='Boolean' or Name/@Image='java.lang.Boolean')]");
16 }
17
18 public void testAll() {
19 runTests(new TestDescriptor[] {
20 new TestDescriptor(TEST1, "simple failure case", 1, rule),
21 new TestDescriptor(TEST2, "new java.lang.Boolean", 1, rule),
22 new TestDescriptor(TEST3, "ok", 0, rule),
23 });
24 }
25
26 private static final String TEST1 =
27 "public class Foo {" + PMD.EOL +
28 " Boolean b = new Boolean(\"true\");" + PMD.EOL +
29 "}";
30
31 private static final String TEST2 =
32 "public class Foo {" + PMD.EOL +
33 " Boolean b = new java.lang.Boolean(\"true\");" + PMD.EOL +
34 "}";
35
36 private static final String TEST3 =
37 "public class Foo {" + PMD.EOL +
38 " Boolean b = Boolean.TRUE;" + PMD.EOL +
39 "}";
40
41 }
This page was automatically generated by Maven