1 package test.net.sourceforge.pmd.rules;
2
3 import net.sourceforge.pmd.PMD;
4 import net.sourceforge.pmd.Rule;
5 import net.sourceforge.pmd.rules.XPathRule;
6
7 public class UnusedModifierRuleTest extends SimpleAggregatorTst {
8
9 private Rule rule;
10
11 public void setUp() {
12 rule = new XPathRule();
13 rule.addProperty("xpath", "//InterfaceDeclaration//MethodDeclaration[@Public='true' or @Abstract = 'true']");
14 }
15
16 public void testAll() {
17 runTests(new TestDescriptor[] {
18 new TestDescriptor(TEST1, "wasted 'public'", 1, rule),
19 new TestDescriptor(TEST2, "class, no problem", 0, rule),
20 new TestDescriptor(TEST3, "wasted 'abstract'", 1, rule),
21 new TestDescriptor(TEST4, "all is well", 0, rule)
22 });
23 }
24
25 private static final String TEST1 =
26 "public interface Foo {" + PMD.EOL +
27 " public void bar();" + PMD.EOL +
28 "}";
29
30 private static final String TEST2 =
31 "public abstract class Foo {" + PMD.EOL +
32 " public abstract void bar();" + PMD.EOL +
33 "}";
34
35 private static final String TEST3 =
36 "public interface Foo {" + PMD.EOL +
37 " abstract void bar();" + PMD.EOL +
38 "}";
39
40 private static final String TEST4 =
41 "public interface Foo {" + PMD.EOL +
42 " void bar();" + PMD.EOL +
43 "}";
44
45 }
This page was automatically generated by Maven