    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.RuleSetNotFoundException;
    6   import test.net.sourceforge.pmd.testframework.SimpleAggregatorTst;
    7   import test.net.sourceforge.pmd.testframework.TestDescriptor;
    8
    9   public class UseArrayListInsteadOfVectorTest extends SimpleAggregatorTst {
    10
    11      private Rule rule;
    12
    13      public void setUp() throws RuleSetNotFoundException {
    14          rule = findRule("optimizations", "UseArrayListInsteadOfVector");
    15      }
    16
    17      public void testAll() {
    18          runTests(new TestDescriptor[]{
    19              new TestDescriptor(TEST0, "TEST0", 0, rule),
    20              new TestDescriptor(TEST1, "TEST1", 1, rule),
    21              new TestDescriptor(TEST2, "TEST2", 1, rule),
    22              new TestDescriptor(TEST3, "TEST3", 1, rule),
    23          });
    24      }
    25
    26
    27      private static final String TEST0 =
    28              "public class Bar {" + PMD.EOL +
    29              " void x() {" + PMD.EOL +
    30              "  List v = new ArrayList(); " + PMD.EOL +
    31              " }" + PMD.EOL +
    32              "}";
    33
    34      private static final String TEST1 =
    35              "public class Bar {" + PMD.EOL +
    36              " void x() {" + PMD.EOL +
    37              "  Vector v = new Vector(); " + PMD.EOL +
    38              " }" + PMD.EOL +
    39              "}";
    40
    41      private static final String TEST2 =
    42              "public class Bar {" + PMD.EOL +
    43              " Vector v = new Vector(); " + PMD.EOL +
    44              " void x() {}" + PMD.EOL +
    45              "}";
    46
    47      private static final String TEST3 =
    48              "public class Bar {" + PMD.EOL +
    49              " List v = new Vector(); " + PMD.EOL +
    50              " void x() {}" + PMD.EOL +
    51              "}";
    52
    53  }