    1   /*
    2    * Created on Jan 19, 2005
    3    *
    4    * $Id: ASTThrowStatementTest.java,v 1.6 2006/02/10 14:26:25 tomcopeland Exp $
    5    */
    6   package test.net.sourceforge.pmd.ast;
    7
    8   import net.sourceforge.pmd.PMD;
    9   import net.sourceforge.pmd.ast.ASTThrowStatement;
    10  import test.net.sourceforge.pmd.testframework.ParserTst;
    11
    12  /***
    13   * @author mgriffa
    14   */
    15  public class ASTThrowStatementTest extends ParserTst {
    16
    17      public final void testGetFirstASTNameImageNull() throws Throwable {
    18          ASTThrowStatement t = (ASTThrowStatement) getNodes(ASTThrowStatement.class, NULL_NAME).iterator().next();
    19          assertNull(t.getFirstClassOrInterfaceTypeImage());
    20      }
    21
    22      public final void testGetFirstASTNameImageNew() throws Throwable {
    23          ASTThrowStatement t = (ASTThrowStatement) getNodes(ASTThrowStatement.class, OK_NAME).iterator().next();
    24          assertEquals("FooException", t.getFirstClassOrInterfaceTypeImage());
    25      }
    26
    27      private static final String NULL_NAME =
    28              "public class Test {" + PMD.EOL +
    29              "  void bar() {" + PMD.EOL +
    30              "   throw e;" + PMD.EOL +
    31              "  }" + PMD.EOL +
    32              "}";
    33
    34      private static final String OK_NAME =
    35              "public class Test {" + PMD.EOL +
    36              "  void bar() {" + PMD.EOL +
    37              "   throw new FooException();" + PMD.EOL +
    38              "  }" + PMD.EOL +
    39              "}";
    40  }