1 package test.net.sourceforge.pmd.ast; 2 3 import net.sourceforge.pmd.PMD; 4 import net.sourceforge.pmd.TargetJDK1_4; 5 import net.sourceforge.pmd.TargetJDK1_5; 6 import net.sourceforge.pmd.ast.ASTAnnotation; 7 import net.sourceforge.pmd.ast.ParseException; 8 9 import org.junit.Test; 10 11 import test.net.sourceforge.pmd.testframework.ParserTst; 12 13 public class ASTAnnotationTest extends ParserTst { 14 15 @Test 16 public void testAnnotationSucceedsWithDefaultMode() throws Throwable { 17 getNodes(ASTAnnotation.class, TEST1); 18 } 19 20 @Test(expected = ParseException.class) 21 public void testAnnotationFailsWithJDK14() throws Throwable { 22 getNodes(new TargetJDK1_4(), ASTAnnotation.class, TEST1); 23 } 24 25 @Test 26 public void testAnnotationSucceedsWithJDK15() throws Throwable { 27 getNodes(new TargetJDK1_5(), ASTAnnotation.class, TEST1); 28 } 29 30 private static final String TEST1 = 31 "public class Foo extends Buz {" + PMD.EOL + 32 " @Override" + PMD.EOL + 33 " void bar() {" + PMD.EOL + 34 " // overrides a superclass method" + PMD.EOL + 35 " }" + PMD.EOL + 36 "}"; 37 38 public static junit.framework.Test suite() { 39 return new junit.framework.JUnit4TestAdapter(ASTAnnotationTest.class); 40 } 41 }