    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.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 LongParameterListRuleTest extends SimpleAggregatorTst {
    13
    14      private Rule rule;
    15
    16      public void setUp() throws RuleSetNotFoundException {
    17          rule = findRule("codesize", "ExcessiveParameterList");
    18          rule.addProperty("minimum", "9");
    19      }
    20
    21      public void testAll() {
    22          runTests(new TestDescriptor[]{
    23              new TestDescriptor(TEST1, "short", 0, rule),
    24              new TestDescriptor(TEST2, "long", 1, rule),
    25          });
    26      }
    27
    28      private static final String TEST1 =
    29              "public class Foo {" + PMD.EOL +
    30              "    public void foo() {}" + PMD.EOL +
    31              "}";
    32
    33      private static final String TEST2 =
    34              "public class Foo {" + PMD.EOL +
    35              "    public void foo(int p01, int p02, int p03, int p04, int p05, int p06, int p07, int p08, int p09, int p10 ) { }" + PMD.EOL +
    36              "    public void bar(int p01, int p02, int p03, int p04, int p05 ) { }" + PMD.EOL +
    37              "}";
    38  }