    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.rules.MethodNamingConventions;
    8   import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
    9   import test.net.sourceforge.pmd.testframework.TestDescriptor;
    10
    11  public class MethodNamingConventionsTest extends SimpleAggregatorTst {
    12
    13      public void testAll() {
    14          runTests(new TestDescriptor[]{
    15              new TestDescriptor(TEST1, "method names should start with lowercase character", 1, new MethodNamingConventions()),
    16              new TestDescriptor(TEST2, "method names should not contain underscores", 1, new MethodNamingConventions()),
    17              new TestDescriptor(TEST3, "all is well", 0, new MethodNamingConventions()),
    18          });
    19      }
    20
    21      private static final String TEST1 =
    22              "public class Foo {" + PMD.EOL +
    23              " void Bar() {}" + PMD.EOL +
    24              "}";
    25
    26      private static final String TEST2 =
    27              "public class Foo {" + PMD.EOL +
    28              " void bar_foo() {}" + PMD.EOL +
    29              "}";
    30
    31      private static final String TEST3 =
    32              "public class Foo {" + PMD.EOL +
    33              " void foo() {}" + PMD.EOL +
    34              "}";
    35  }