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.LongParameterListRule;
8   import test.net.sourceforge.pmd.testframework.RuleTst;
9   
10  public class LongParameterListRuleTest extends RuleTst {
11  
12      private static final String TEST1 =
13      "public class LongParameterList0 {" + PMD.EOL +
14      "    public void foo() {}" + PMD.EOL +
15      "}";
16  
17      private static final String TEST2 =
18      "public class LongParameterList1 {" + PMD.EOL +
19      "    public void foo(int p01, int p02, int p03, int p04, int p05," + PMD.EOL +
20      "                   int p06, int p07, int p08, int p09, int p10 ) { }" + PMD.EOL +
21      "    public void bar(int p01, int p02, int p03, int p04, int p05 ) { }" + PMD.EOL +
22      "}";
23  
24      public LongParameterListRule getIUT() {
25          LongParameterListRule IUT = new LongParameterListRule();
26          IUT.addProperty("minimum", "9");
27          return IUT;
28      }
29  
30      public void testShortMethod() throws Throwable {
31          runTestFromString(TEST1, 0, getIUT());
32      }
33  
34      public void testOneLongMethod() throws Throwable {
35          runTestFromString(TEST2, 1, getIUT());
36      }
37  }