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