01: package test.net.sourceforge.pmd.ast;
02:
03: import net.sourceforge.pmd.PMD;
04: import net.sourceforge.pmd.TargetJDK1_4;
05: import net.sourceforge.pmd.TargetJDK1_5;
06: import net.sourceforge.pmd.ast.ASTAnnotation;
07: import net.sourceforge.pmd.ast.ParseException;
08:
09: 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()
17: throws Throwable {
18: getNodes(ASTAnnotation.class, TEST1);
19: }
20:
21: @Test(expected=ParseException.class)
22: public void testAnnotationFailsWithJDK14() throws Throwable {
23: getNodes(new TargetJDK1_4(), ASTAnnotation.class, TEST1);
24: }
25:
26: @Test
27: public void testAnnotationSucceedsWithJDK15() throws Throwable {
28: getNodes(new TargetJDK1_5(), ASTAnnotation.class, TEST1);
29: }
30:
31: private static final String TEST1 = "public class Foo extends Buz {"
32: + PMD.EOL
33: + " @Override"
34: + PMD.EOL
35: + " void bar() {"
36: + PMD.EOL
37: + " // overrides a superclass method"
38: + PMD.EOL
39: + " }" + PMD.EOL + "}";
40:
41: public static junit.framework.Test suite() {
42: return new junit.framework.JUnit4TestAdapter(
43: ASTAnnotationTest.class);
44: }
45: }
|