1 /*** 2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html 3 */ 4 package test.net.sourceforge.pmd.rules; 5 6 import net.sourceforge.pmd.PMD; 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 UncommentedEmptyMethodRuleTest extends SimpleAggregatorTst { 12 13 private Rule rule; 14 15 public void setUp() { 16 rule = findRule("design", "UncommentedEmptyMethod"); 17 } 18 19 public void testAll() { 20 runTests(new TestDescriptor[]{ 21 new TestDescriptor(TEST1, "simple failure", 1, rule), 22 new TestDescriptor(TEST2, "single-line comment is OK", 0, rule), 23 new TestDescriptor(TEST3, "multiple-line comment is OK", 0, rule), 24 new TestDescriptor(TEST4, "Javadoc comment is OK", 0, rule), 25 new TestDescriptor(TEST5, "ok", 0, rule), 26 }); 27 } 28 29 public static final String TEST1 = 30 "public class Foo {" + PMD.EOL + 31 " void bar() {" + PMD.EOL + 32 " }" + PMD.EOL + 33 "}"; 34 35 private static final String TEST2 = 36 "public class Foo {" + PMD.EOL + 37 " void bar() {" + PMD.EOL + 38 " // Comment" + PMD.EOL + 39 " }" + PMD.EOL + 40 "}"; 41 42 private static final String TEST3 = 43 "public class Foo {" + PMD.EOL + 44 " void foo() {" + PMD.EOL + 45 " /* Comment */" + PMD.EOL + 46 " }" + PMD.EOL + 47 "}"; 48 49 private static final String TEST4 = 50 "public class Foo {" + PMD.EOL + 51 " void foo() {" + PMD.EOL + 52 " /** Comment */" + PMD.EOL + 53 " }" + PMD.EOL + 54 "}"; 55 56 private static final String TEST5 = 57 "public class Foo {" + PMD.EOL + 58 " void foo() {" + PMD.EOL + 59 " statement();" + PMD.EOL + 60 " }" + PMD.EOL + 61 "}"; 62 }