KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > net > sourceforge > pmd > rules > UncommentedEmptyConstructorRuleTest


1
2  /**
3   * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
4   */

5  package test.net.sourceforge.pmd.rules;
6  
7  import net.sourceforge.pmd.Rule;
8  import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
9  import test.net.sourceforge.pmd.testframework.TestDescriptor;
10  
11  public class UncommentedEmptyConstructorRuleTest extends SimpleAggregatorTst {
12  
13      private Rule rule;
14      private TestDescriptor[] tests;
15  
16      public void setUp() {
17          rule = findRule("design", "UncommentedEmptyConstructor");
18          tests = extractTestsFromXml(rule);
19      }
20  
21      public void testDefault() {
22          runTests(tests);
23      }
24  
25      public void testIgnoredConstructorInvocation() {
26          rule.addProperty("ignoreExplicitConstructorInvocation", "true");
27          runTests(new TestDescriptor[]{
28              new TestDescriptor(tests[0].getCode(), "simple failure", 1, rule),
29              new TestDescriptor(tests[1].getCode(), "only 'this(...)' failure", 1, rule),
30              new TestDescriptor(tests[2].getCode(), "only 'super(...)' failure", 1, rule),
31              new TestDescriptor(tests[3].getCode(), "single-line comment is OK", 0, rule),
32              new TestDescriptor(tests[4].getCode(), "multiple-line comment is OK", 0, rule),
33              new TestDescriptor(tests[5].getCode(), "Javadoc comment is OK", 0, rule),
34              new TestDescriptor(tests[6].getCode(), "ok", 0, rule),
35              new TestDescriptor(tests[7].getCode(), "with 'this(...)' ok", 0, rule),
36              new TestDescriptor(tests[8].getCode(), "with 'super(...)' ok", 0, rule),
37              new TestDescriptor(tests[9].getCode(), "private is ok", 0, rule),
38          });
39      }
40  }
41
Popular Tags