01: /**
02: * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03: */package test.net.sourceforge.pmd.rules.design;
04:
05: import org.junit.Before;
06: import org.junit.Test;
07:
08: import net.sourceforge.pmd.Rule;
09: import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
10: import test.net.sourceforge.pmd.testframework.TestDescriptor;
11:
12: public class UncommentedEmptyConstructorRuleTest extends
13: SimpleAggregatorTst {
14:
15: private Rule rule;
16: private TestDescriptor[] tests;
17:
18: @Before
19: public void setUp() {
20: rule = findRule("design", "UncommentedEmptyConstructor");
21: tests = extractTestsFromXml(rule);
22: }
23:
24: @Test
25: public void testDefault() {
26: runTests(tests);
27: }
28:
29: @Test
30: public void testIgnoredConstructorInvocation() {
31: rule.addProperty("ignoreExplicitConstructorInvocation", "true");
32: runTests(new TestDescriptor[] {
33: new TestDescriptor(tests[0].getCode(),
34: "simple failure", 1, rule),
35: new TestDescriptor(tests[1].getCode(),
36: "only 'this(...)' failure", 1, rule),
37: new TestDescriptor(tests[2].getCode(),
38: "only 'super(...)' failure", 1, rule),
39: new TestDescriptor(tests[3].getCode(),
40: "single-line comment is OK", 0, rule),
41: new TestDescriptor(tests[4].getCode(),
42: "multiple-line comment is OK", 0, rule),
43: new TestDescriptor(tests[5].getCode(),
44: "Javadoc comment is OK", 0, rule),
45: new TestDescriptor(tests[6].getCode(), "ok", 0, rule),
46: new TestDescriptor(tests[7].getCode(),
47: "with 'this(...)' ok", 0, rule),
48: new TestDescriptor(tests[8].getCode(),
49: "with 'super(...)' ok", 0, rule),
50: new TestDescriptor(tests[9].getCode(), "private is ok",
51: 0, rule), });
52: }
53:
54: public static junit.framework.Test suite() {
55: return new junit.framework.JUnit4TestAdapter(
56: UncommentedEmptyConstructorRuleTest.class);
57: }
58: }
|