    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 UnnecessaryTemporariesTest extends SimpleAggregatorTst {
    12
    13      private Rule rule;
    14
    15      public void setUp() throws Exception {
    16          rule = findRule("basic", "UnnecessaryConversionTemporary");
    17      }
    18
    19      public void testAll() {
    20          runTests(new TestDescriptor[]{
    21              new TestDescriptor(TEST1, "all glommed together", 6, rule),
    22          });
    23      }
    24
    25      private static final String TEST1 =
    26              " public class Foo {" + PMD.EOL +
    27              "     void method (int x) {" + PMD.EOL +
    28              "        new Integer(x).toString(); " + PMD.EOL +
    29              "        new Long(x).toString(); " + PMD.EOL +
    30              "        new Float(x).toString(); " + PMD.EOL +
    31              "        new Byte((byte)x).toString(); " + PMD.EOL +
    32              "        new Double(x).toString(); " + PMD.EOL +
    33              "        new Short((short)x).toString(); " + PMD.EOL +
    34              "     }" + PMD.EOL +
    35              " }";
    36  }