1 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 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 } 41 | Popular Tags |