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