1   package test.net.sourceforge.pmd.ast;
2   
3   import net.sourceforge.pmd.PMD;
4   import net.sourceforge.pmd.TargetJDK1_5;
5   import net.sourceforge.pmd.ast.ASTAnnotation;
6   import net.sourceforge.pmd.ast.ParseException;
7   import test.net.sourceforge.pmd.testframework.ParserTst;
8   
9   public class ASTAnnotationTest extends ParserTst {
10  
11      public void testAnnotationFailsWithJDK14() throws Throwable {
12          try {
13              getNodes(ASTAnnotation.class, TEST1);
14              // FIXME fail("Should have failed to parse an annotation in JDK 1.4 mode");
15          } catch (ParseException pe) {
16              // cool
17          }
18      }
19  
20      public void testAnnotationSucceedsWithJDK15() throws Throwable {
21          try {
22              getNodes(new TargetJDK1_5(), ASTAnnotation.class, TEST1);
23          } catch (ParseException pe) {
24              pe.printStackTrace();
25              fail("Should have been able to parse an annotation in JDK 1.5 mode");
26          }
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  }