1 /***
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package test.net.sourceforge.pmd.rules.design;
5
6 import net.sourceforge.pmd.PMD;
7 import net.sourceforge.pmd.rules.design.LongClassRule;
8 import test.net.sourceforge.pmd.testframework.RuleTst;
9
10 public class LongClassRuleTest extends RuleTst {
11
12 public LongClassRule getIUT() {
13 LongClassRule IUT = new LongClassRule();
14 IUT.addProperty("minimum", "10");
15 return IUT;
16 }
17
18 public void testShortClass() throws Throwable {
19 runTestFromString(TEST0, 0, getIUT());
20 }
21
22 public void testLongClass() throws Throwable {
23 runTestFromString(TEST1, 1, getIUT());
24 }
25
26 public void testLongClassWithLongerTest() throws Throwable {
27 LongClassRule IUT = getIUT();
28 IUT.addProperty("minimum", "2000");
29 runTestFromString(TEST1, 0, IUT);
30 }
31
32 private static final String TEST0 =
33 "public class LongMethod1 {" + PMD.EOL +
34 " public static void main(String args[]) {" + PMD.EOL +
35 " System.err.println(\"This is short.\");" + PMD.EOL +
36 " }" + PMD.EOL +
37 "}";
38
39 private static final String TEST1 =
40 "public class LongClass1" + PMD.EOL +
41 "{" + PMD.EOL +
42 " public void method0() {" + PMD.EOL +
43 " System.err.println(\"This is a long class.\");" + PMD.EOL +
44 " System.err.println(\"This is a long class.\");" + PMD.EOL +
45 " System.err.println(\"This is a long class.\");" + PMD.EOL +
46 " System.err.println(\"This is a long class.\");" + PMD.EOL +
47 " System.err.println(\"This is a long class.\");" + PMD.EOL +
48 " System.err.println(\"This is a long class.\");" + PMD.EOL +
49 " System.err.println(\"This is a long class.\");" + PMD.EOL +
50 " System.err.println(\"This is a long class.\");" + PMD.EOL +
51 " System.err.println(\"This is a long class.\");" + PMD.EOL +
52 " System.err.println(\"This is a long class.\");" + PMD.EOL +
53 " System.err.println(\"This is a long class.\");" + PMD.EOL +
54 " System.err.println(\"This is a long class.\");" + PMD.EOL +
55 " System.err.println(\"This is a long class.\");" + PMD.EOL +
56 " }" + PMD.EOL +
57 "}";
58 }
59
This page was automatically generated by Maven