View Javadoc

    1   /**
    2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
    3    */
    4   package net.sourceforge.pmd;
    5
    6   import static org.junit.Assert.assertEquals;
    7
    8   import java.util.Set;
    9
    10  import net.sourceforge.pmd.lang.java.ast.ASTPackageDeclaration;
    11  import net.sourceforge.pmd.testframework.ParserTst;
    12
    13  import org.junit.Test;
    14
    15  public class ASTPackageDeclarationTest extends ParserTst {
    16
    17  	private static final String PACKAGE_INFO_ANNOTATED = "@Deprecated" + PMD.EOL
    18  			+ "package net.sourceforge.pmd.foobar;" + PMD.EOL;
    19
    20  	/**
    21  	 * Regression test for bug 3524607.
    22  	 * @throws Throwable any error
    23  	 */
    24  	@Test
    25  	public void testPackageName() throws Throwable {
    26  		Set<ASTPackageDeclaration> nodes = getNodes(ASTPackageDeclaration.class, PACKAGE_INFO_ANNOTATED);
    27
    28  		assertEquals(1, nodes.size());
    29  		ASTPackageDeclaration packageNode = nodes.iterator().next();
    30  		assertEquals("net.sourceforge.pmd.foobar", packageNode.getPackageNameImage());
    31  	}
    32  }