1 /***
2 * <copyright>
3 * Copyright 1997-2002 InfoEther, LLC
4 * under sponsorship of the Defense Advanced Research Projects Agency
5 (DARPA).
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the Cougaar Open Source License as published
9 by
10 * DARPA on the Cougaar Open Source Website (www.cougaar.org).
11 *
12 * THE COUGAAR SOFTWARE AND ANY DERIVATIVE SUPPLIED BY LICENSOR IS
13 * PROVIDED 'AS IS' WITHOUT WARRANTIES OF ANY KIND, WHETHER EXPRESS OR
14 * IMPLIED, INCLUDING (BUT NOT LIMITED TO) ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND WITHOUT
16 * ANY WARRANTIES AS TO NON-INFRINGEMENT. IN NO EVENT SHALL COPYRIGHT
17 * HOLDER BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT OR CONSEQUENTIAL
18 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE OF DATA OR PROFITS,
19 * TORTIOUS CONDUCT, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THE COUGAAR SOFTWARE.
21 * </copyright>
22 */
23 package test.net.sourceforge.pmd.rules;
24
25 import net.sourceforge.pmd.PMD;
26 import net.sourceforge.pmd.rules.ExcessivePublicCountRule;
27 import test.net.sourceforge.pmd.testframework.RuleTst;
28
29 public class ExcessivePublicCountRuleTest extends RuleTst {
30
31 private ExcessivePublicCountRule rule;
32
33 public void setUp() {
34 rule = new ExcessivePublicCountRule();
35 }
36
37 public void testSimpleOK() throws Throwable {
38 rule.addProperty("minimum", "50");
39 runTestFromString(TEST1, 0, rule);
40 }
41
42 public void testSimpleBad() throws Throwable {
43 rule.addProperty("minimum", "2");
44 runTestFromString(TEST2, 1, rule);
45 }
46
47 private static final String TEST1 =
48 "public class ExcessivePublicCountRule1 {" + PMD.EOL +
49 " public int foo;" + PMD.EOL +
50 "}";
51
52 private static final String TEST2 =
53 "public class ExcessivePublicCountRule2 {" + PMD.EOL +
54 " public int foo;" + PMD.EOL +
55 " public int bif;" + PMD.EOL +
56 " public int baz;" + PMD.EOL +
57 " public int bof;" + PMD.EOL +
58 "}";
59
60 }
This page was automatically generated by Maven