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.RuleSetNotFoundException;
9 import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
10 import test.net.sourceforge.pmd.testframework.TestDescriptor;
11
12 public class LongVariableRuleTest extends SimpleAggregatorTst {
13
14 private Rule rule;
15
16 public void setUp() throws RuleSetNotFoundException {
17 rule = findRule("rulesets/naming.xml", "LongVariable");
18 }
19
20 public void testAll() {
21 runTests(new TestDescriptor[] {
22 new TestDescriptor(TEST1, "param", 1, rule),
23 new TestDescriptor(TEST2, "ok", 0, rule),
24 new TestDescriptor(TEST3, "local", 1, rule),
25 new TestDescriptor(TEST4, "field", 1, rule),
26 new TestDescriptor(TEST5, "for", 1, rule),
27 });
28 }
29
30 private static final String TEST1 =
31 "public class Foo {" + PMD.EOL +
32 " void foo(String argsWithExtraMustard) {} " + PMD.EOL +
33 "}";
34
35 private static final String TEST2 =
36 "public class Foo {" + PMD.EOL +
37 " void foo() {" + PMD.EOL +
38 " int bugleDeWump = -1;" + PMD.EOL +
39 " }" + PMD.EOL +
40 "}";
41
42 private static final String TEST3 =
43 "public class Foo {" + PMD.EOL +
44 "" + PMD.EOL +
45 " void foo() {" + PMD.EOL +
46 " int abcdefghijklmnopqrstuvwxyz = -1; " + PMD.EOL +
47 " }" + PMD.EOL +
48 "}";
49
50 private static final String TEST4 =
51 "public class Foo {" + PMD.EOL +
52 " void foo() {" + PMD.EOL +
53 " for (int interestingIntIterator = 0; " + PMD.EOL +
54 " interestingIntIterator < 10; " + PMD.EOL +
55 " interestingIntIterator++) { }" + PMD.EOL +
56 " }" + PMD.EOL +
57 "}";
58
59 private static final String TEST5 =
60 "public class Foo {" + PMD.EOL +
61 " private int abcdefghijklmnopqrstuvwxyz;" + PMD.EOL +
62 "}";
63
64 }