    1   /***
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package test.net.sourceforge.pmd.rules.junit;
    5
    6   import net.sourceforge.pmd.PMD;
    7   import net.sourceforge.pmd.Rule;
    8   import net.sourceforge.pmd.RuleSetNotFoundException;
    9   import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
    10  import test.net.sourceforge.pmd.testframework.TestDescriptor;
    11
    12  public class UseAssertEqualsInsteadOfAssertTrueTest extends SimpleAggregatorTst {
    13      private Rule rule;
    14
    15      public void setUp() throws RuleSetNotFoundException {
    16          rule = findRule("junit", "UseAssertEqualsInsteadOfAssertTrue");
    17      }
    18
    19      public void testAll() throws Throwable {
    20
    21          runTests(new TestDescriptor[]{
    22              new TestDescriptor(TEST1, "TEST1", 0, rule),
    23              new TestDescriptor(TEST2, "TEST2", 1, rule),
    24              new TestDescriptor(TEST3, "TEST3", 0, rule),
    25          });
    26      }
    27
    28      private static final String TEST1 =
    29              "public class Foo {" + PMD.EOL +
    30              " public void test1() {" + PMD.EOL +
    31              "  assertTrue(a==b);" + PMD.EOL +
    32              " }" + PMD.EOL +
    33              "}";
    34
    35      private static final String TEST2 =
    36              "public class Foo {" + PMD.EOL +
    37              " public void test1() {" + PMD.EOL +
    38              "  assertTrue(a.equals(b));" + PMD.EOL +
    39              " }" + PMD.EOL +
    40              "}";
    41
    42      private static final String TEST3 =
    43              "public class Foo {" + PMD.EOL +
    44              " public void test1() {" + PMD.EOL +
    45              "  assertTrue(a.mySpecialequals(b));" + PMD.EOL +
    46              " }" + PMD.EOL +
    47              "}";
    48
    49  }