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.rules.XPathRule;
7 import net.sourceforge.pmd.PMD;
8
9 public class AvoidDollarSignsRuleTest extends SimpleAggregatorTst {
10
11 private Rule rule;
12
13 public void setUp() {
14 rule = new XPathRule();
15 rule.addProperty("xpath", "//UnmodifiedClassDeclaration[contains(@Image, '$')]|//VariableDeclaratorId[contains(@Image, '$')]|//UnmodifiedInterfaceDeclaration[contains(@Image, '$')]|//MethodDeclarator[contains(@Image, '$')]");
16 }
17
18 public void testAll() {
19 runTests(new TestDescriptor[] {
20 new TestDescriptor(TEST1, "class Fo$o", 1, rule),
21 new TestDescriptor(TEST2, "variable fo$oo", 1, rule),
22 new TestDescriptor(TEST3, "method foo$oo", 1, rule),
23 new TestDescriptor(TEST4, "interface fo$oo", 1, rule),
24 new TestDescriptor(TEST5, "ok", 0, rule),
25 });
26 }
27
28 private static final String TEST1 =
29 "public class F$oo {}";
30
31 private static final String TEST2 =
32 "public class Foo {" + PMD.EOL +
33 " int fo$o;" + PMD.EOL +
34 "}";
35
36 private static final String TEST3 =
37 "public class Foo {" + PMD.EOL +
38 " void fo$o() {}" + PMD.EOL +
39 "}";
40
41 private static final String TEST4 =
42 "public interface Foo$oo {}";
43
44 private static final String TEST5 =
45 "public class Foo {" + PMD.EOL +
46 " void foo() {}" + PMD.EOL +
47 " int buz;" + PMD.EOL +
48 "}" + PMD.EOL +
49 "public interface Baz {} ";
50
51 }
This page was automatically generated by Maven